Step1: interface design
, there are three horizontal layouts in the interface, the first horizontal layout of city is the text input box, the message is: Please enter pinyin (prompted to enter pinyin, is the requirements of the Baidu interface provisions), query and clear are buttons, the second layout has two labels, headinfo is used to display the information, info is used to display the basic information returned, and the third layout contains two labels, headweather is used to display the prompt information, Weather is used to display weather forecast information. A non-visual component adds a Web client to access the Weather forecast API interface.
STEP2: Logical Design
1. Initialize Global variables
The globallist is used to store JSON data returned from the interface, and NewList is used to store the processed data.
2, defining procedure to parse JSON data (flatten multilevel list to level two list)
4, processing data returned by Web page
infollist and weatherlist are local variables that are used to access city information data and weather forecast data, Globallist is used to store the JSON data returned by the client, and next calls the process of parsing the JSON data, passing globallist as a parameter. After calling this process, the flattened level two list has already been stored in the variable newlist, so we can easily find the city information in the newlist with the keyword "basic" and find the real-time weather information through the keyword "Now".
finally took the city name, country name and weather conditions in infolist and weatherlist by the corresponding keywords. (Because the weather forecast data is more complex, not all of them read, the clouds can choose the information they need to display it according to the actual situation)
5, Set" empty "button code
When you click the button" empty ", the current list and display information is emptied to avoid the impact of the last access data retention on this visit.
/span>
STEP3: Testing
A porter who does not do internet in the cloud
Insist on sharing practical information and original information technology tutorials
Using Appinventor to read the weather interface (full version)