=============== Problem description ====================
A function is provided to parse the JSON data of Baidu weather. gson resolution is used in results. Now the data displayed in the log has been parsed, but only the last one can be displayed on the textview interface. settext (). Why?
List<WeatherInfo.index> myIndex = weatherInfo.getIndex();for (index in : myIndex) {Log.i(TGA, "Des = " + in.getTipt() + ":" + in.getDes());indexContent.setText(in.getTipt() + ":" + in.getDes() + "\n");}
============= Solution 1 ======================
The text of textview is re-set every cycle, not the text of the last set ..
============= Solution 2 ======================
Get a stringbuffer as a global variable, append each time there is something new, and finally settext (buffer. tostring ())
However, we recommend that you use listview to parse the data you have read and then use the adapter to display it.
============= Solution 3 ======================
The third floor method can be changed as follows: String STR = "";
For (index in: myindex ){
STR + = (in. gettipt () + ":" + in. getdes () + "\ n ");
}
Indexcontent. settext (STR );
Consult experts! Why is my data displayed in the log, but only the last data is displayed in. settext?