Friday, 15 July 2011

android list view footer is not displaying -



android list view footer is not displaying -

i adding list items list view like

if have 50 list items, loading first 10 items , remaining 10 items , on...

you can find portion of code here reverence...

itemsperpage=10; list = (listview) findviewbyid(r.id.list1); footerview = ((layoutinflater) .getsystemservice(context.layout_inflater_service)).inflate( r.layout.footer, null, false); list.addfooterview(footerview); adapter.addall(getitemsbetween(0, itemsperpage));// loading first 10 items

and here scrolling code...

list.setonscrolllistener(new abslistview.onscrolllistener() { @override public void onscrollstatechanged(abslistview view, int scrollstate) { } @override public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { if (totalitemcount <= totalcount) { // bottom iten visible int lastinscreen = firstvisibleitem + visibleitemcount; if ((lastinscreen == totalitemcount)){ int currentitemcount= mostviewdadapter.getcount(); mostviewdadapter.addall(getitemsbetween(currentitemcount, currentitemcount+itemsperpage)); mostviewdadapter.notifydatasetchanged(); } }else{ system.out.println("end of list view reached"); footerview.setvisibility(view.gone); } } });

here sharing footer xml:

<progressbar android:id="@+id/footerbar" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <textview android:id="@id/android:empty" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:padding="5dp" android:text="loading..." />

have @ next code 1) add together custom_listview_footer.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingbottom="7dip" android:paddingtop="7dip" > <button android:id="@+id/btn_invite" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginbottom="5dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:layout_weight="0" android:text="load more" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> 2) in activity phone call view footerview = ((layoutinflater) _con .getsystemservice(context.layout_inflater_service)).inflate( r.layout.custom_listview_footer, null, false); 3) phone call button of footer view button btninvite = (button) footerview.findviewbyid(r.id.btn_invite); 4) lastly add together footer listview lvphncontacts.addfooterview(footerview);

android android-listview

No comments:

Post a Comment