2

I am getting data from Database and displaying using a custom list adapter in a ListView.

I need to display only 10 items in ListView. and after 10th item a button show with text "Show More", when click this button so show more 10 items from Database in listview.

How i can do this?

Please let me know with code example

Thanks

Bishan
  • 15,211
  • 52
  • 164
  • 258
  • See this Link..[Link ][1] [1]: http://stackoverflow.com/questions/2386593/how-to-show-a-button-at-the-end-of-an-android-listview –  Apr 09 '12 at 09:56

1 Answers1

12

In Base Adapter, initially take i=10; then use this "i" in getCount() method of BaseAdapter.

public int getCount() {
// TODO Auto-generated method stub
return i;
}

And in your "show more" Button click Increment the i, then call adapter.

Ex:

i=i+10;
adapter.notifyDataSetChanged();
Abhi
  • 8,935
  • 7
  • 37
  • 60
  • 1
    Short and accurate answer... +1 ! – Hiral Vadodaria Apr 09 '12 at 09:21
  • Being new to Java (from C#) I'm a little confused on how i gets to the BaseAdapter override. In my mind wouldn't you have to pass i in the constructor of NamesAdapter (referencing the pastebin sample)? – GPGVM May 16 '12 at 14:52