Traditional Culture Encyclopedia - Weather inquiry - Android Development: How does the weather forecast locate the city?
Android Development: How does the weather forecast locate the city?
(1) Modify the layout file main.xml in the res\layout directory of new projects, delete the text view component added by default, then add the horizontal linear layout manager and the Web view level component for displaying web pages, and add buttons for Beijing, Shanghai, Harbin, Changchun and Shenyang in the layout manager.
(2) In the MainActivity, declare the object webView of a Web View component. The specific code is as follows:
(In the onCreateO method, firstly, get the Web View component added in the layout manager, then set it to allow JavaScript to be used, and handle JavaScript dialog boxes and various request events, then specify the weather forecast information to be loaded for the Web View component, and finally enlarge the content of the webpage by 4 times. The specific code is as follows:
(4) Let the MainActivity implement the OnClickListener interface to add the click event listener. The modified code is as follows:
- Previous article:Apple 1 1 How to set the weather city?
- Next article:Complete works of classic folk historical stories
- Related articles
- What is "high temperature insurance"? Is it reliable? How much can I buy at most?
- Pidao related history
- Comments on family education lectures during the epidemic period
- Recently, it has been raining continuously in Sanya бн When will it be sunny for friends in Sanya? September 17 My friends and I are going to Sanya for a week.
- Describe a fidgety mood
- Ask for the funniest joke
- Parent-child trip in central Japan
- What museums are worth seeing in Heilongjiang?
- 90-day weather forecast in Sanya
- Eczema is getting itchy? How to care for eczema?