Recently a dynamic Loading ListView class table items, sharing out everyone learn to learn, talk about this example of the implementation process, first of all to limit the load of the list item data for 10 data, when the drag ListView scroll to the last data when loading 10, and displays the load prompt below the listview.
Here is my Java source code:
private void Showcontent () {ListView = (ListView) Findviewbyid (R.id.journals_list_one);
LoadData ();
adapter = new Mylistadapter (this, data);
Footerview = View.inflate (testlayout.this, R.layout.journal_listitem_loading_bar, NULL);
Listview.addfooterview (Footerview, NULL, TRUE);
Listview.setadapter (adapter);
Listview.setonscrolllistener (listener); Private Abslistview.onscrolllistener listener = new Abslistview.onscrolllistener () {@Override public void ONSC
Rollstatechanged (abslistview view, int scrollstate) {if (view.getlastvisibleposition () = = View.getcount ()-1) {
LoadData ();
Adapter.notifydatasetchanged (); @Override public void Onscroll (Abslistview view, int firstvisibleitem, int visibleitemcount, int total
ItemCount) {}};
/** * Construct list data/private void LoadData () {if (Data.size () <=) {for (int i = 0; i < i++) { map<string, string> map = new HASHMAp<string, string> ();
Map.put ("title", GetString (R.string.title));
Map.put ("desc", GetString (r.string.content));
Data.add (map);
} else {Listview.removefooterview (Footerview); }
}
Implementation of this function is mainly to add ListView Onscrolllistener listening, to determine whether the list items to the most one, if the last one to load data. The load effect when loading data is that the Listview.addfooterview () method implement this method must be useful before listview.setadapter (). When all the data loading is complete, call Listview.removefooterview to remove Footerview.
If you want to learn more about Android ListView Friends can click to view the topic, more exciting: Android ListView use Method
The above is the entire content of this article, I hope to learn about Android software programming help, but also hope that we support the cloud habitat community.