==================== Problem Description ====================
The code is as follows:
Baseadapter ba=new Baseadapter ()
{
public int GetCount () {
TODO auto-generated Method Stub
return count;
}
Public Object getItem (int arg0) {
TODO auto-generated Method Stub
return null;
}
public long getitemid (int arg0) {
TODO auto-generated Method Stub
return 0;
}
Public View getView (int arg0, view arg1, ViewGroup arg2) {
TODO auto-generated Method Stub
LinearLayout ll=new LinearLayout (showbusactivity.this);
Ll.setorientation (linearlayout.horizontal);
TextView tv1=new TextView (showbusactivity.this);
Tv1.settext (Routeid);
Tv1.settextsize (12);
Tv1.setwidth (120);
Tv1.settextcolor (Color.White);
Ll.addview (TV1);
TextView tv2=new TextView (showbusactivity.this);
Tv2.settext (Tempbus[arg0].strcarid);
Tv2.settextsize (12);
Tv2.setwidth (120);
Tv2.settextcolor (Color.White);
Ll.addview (TV2);
TextView tv3=new TextView (showbusactivity.this);
Tv3.settext (tempbus[arg0].distance);
Tv3.settextsize (12);
Tv3.setwidth (120);
Tv3.settextcolor (Color.White);
Ll.addview (TV3);
TextView tv4=new TextView (showbusactivity.this);
Tv4.settext (tempbus[arg0].direction);
Tv4.settextsize (12);
Tv4.setwidth (120);
Tv4.settextcolor (Color.White);
Ll.addview (TV4);
return ll;
}};
Lv.setadapter (BA);
The contents of Tempbus in the program are updated by the user, I want to display only the updated content in each update, but when the program runs, it will be updated again in Listveiw, and the content before the update is displayed on the ListView. Please help the experts, how to update the data before the contents of the ListView emptied?
==================== Solution 1====================
Tempbus Update Yes! You put the last show tempbus[] Empty the line! Are you textview to clear the light?
==================== Solution 2====================
The author should use the adapter to add the ListView item compared well
To provide you with a thought:
1, when we want to load the item, first empty the list
List.clear ();
Adapter
Adapter1 =new arrayadapter<string> (Getapplicationcontext (), Android. R.layout.simple_list_item_1, list);
Listview.setadapter (Adapter1);
The data in the ListView is emptied after this load.
2, and then load the data we want.
List.add ("a");
List.add ("C");
List.add ("B");
List.add ("a");
List.add ("C");
List.add ("B");
Adapter
Adapter1 =new arrayadapter<string> (Getapplicationcontext (), Android. R.layout.simple_list_item_1, list);
Listview.setadapter (Adapter1);
Adapter1 =new arrayadapter<string> (Getapplicationcontext (), Android. R.layout.simple_list_item_1, list);
Listview.setadapter (Adapter1);
So that we can empty the previous data and get our updated results.
How to empty the contents of the Android ListView control