views:

221

answers:

2

Hi,

I have a listview in my Android Application. Now, when the user presses Next Button other contents will be loaded into the listview. What I want is that if there are no more contents available then there should be a toast displayed indicating that there are no more data available.

Say, for example I have a total of 55 data available and I am displaying only 30 of them in one listview. So, when the user presses Next for the first time next 25 records will be visible. If the user again presses the Next button then a toast should be displayed on top of the last listview that had last 25 records.

Currently I get an error as IndexOutOfBoundException : Invalid location 15 size is 1.

Can someone suggest how is it possible?

Regards

Sunil

A: 

Sound like you're setting the adapter to the items you don't have. So one you need to check your items before updating adapter and then display a toast. TWO - if you have a listView, in my opinion, having NEXT function is not very good design. Why next if you can just scroll ? If you don't want to load everything at one time - do same thing as gmail and load stuff as you go. Example code is courtesy by Mark @ commonsware

here http://stackoverflow.com/questions/1656593/android-endless-adapter

and here : http://github.com/commonsguy/cwac-endless

Alex Volovoy
A: 

Hi,

The problem has been sorted out. It was a simple coding problem. Thanks anyways for taking the timeout to reply.

Regards

Sunil

sunil