I have a list view which loads data from database each time 30 records i.e first hit list will contain 30 item then clicking on view more it will contain 60 item and so on.Now i want that after clicking view more list position will start from 31st position and second hit list position shoould be from 61 and so on. List will contain all value but the start position will be different on every click of view more.
-
you want to... actually what?? Please clean your question, that someone can help you. – Rafael T Jul 09 '12 at 19:20
-
Actually in my database i have a table (Table name A) which contains 10k records.now when i type a in 1 search box list is appended below text box which contain first 30 row and in last view more is appended.if i click on view more 30 more results are fetched from db and added to listview in bottom but list is again showing from 1st row till 60th row.again clicking on view more on bottom 30 results are added to list and list moves to 1 st moving with 90 items now.What exactly i want is list should continue from 31st row then on clicking on view more again it should continue with 61st row . – Gaurav Jul 09 '12 at 19:51
-
@Gaurav -- thanks for adding these details. Consider editing your question to include them rather than leaving them as a comment. – Bob Kaufman Jul 10 '12 at 14:02
2 Answers
Personally, as a user, I do not like that approach much. The way Google Play does it for example is more user-friendly in my opinion: by reaching the end of the list, new items are automatically loaded, giving an almost seamless experience.
You could do that by adding an OnScrollListener to your ListView and check ListView.getFirstVisiblePosition() for figuring out whether the user reaches the end of the list and whether it is necessary to load more items. Do that loading early enough using an AsyncTask. Update your adapter with the result accordingly.

- 5,392
- 1
- 33
- 39
-
Can you please give me a brief description on automatic loading of data to list view.How it is going to hit database and how results are added to list. – Gaurav Jul 09 '12 at 19:58
-
Is you want like a pagination?? i mean when you click 2nd page, it will give you second 30 list items. is it your requirement?? – Arindam Mukherjee Jul 09 '12 at 20:07
-
Yeah exactly it will be like pagination only but it wont contain only the new 30 records but it will contain all the old fetched records which can be seen by scrolling up the list.what i want is every time list will start from the first row of newly added rows. – Gaurav Jul 09 '12 at 20:15
-
Oh, if it is only just that, why don't you just query everything from your database table and use a [CursorAdapter](http://developer.android.com/reference/android/widget/CursorAdapter.html) instead? That should be ok when you don't have to deal with several thousands of records. If you have to deal with more database records, then take a look at following question: http://stackoverflow.com/questions/1407442/android-sqlite-and-huge-data-sets – tiguchi Jul 09 '12 at 20:23
-
i worked on pagination, but not on the way you are asking. actually i did when i am clicking the button, i am again connecting to the server and getting the data. which are next 30 records. And when you again go back to previous page, it will show the old records. – Arindam Mukherjee Jul 09 '12 at 20:24
Actually it was not that complicated what i felt.Today when i started working on it i managed to get the list like i expected.Every time when new rows are added to list i just set the list starting selection at the first item from newly added row by using resultList.setSelection(limitVal - 29) ..here limitVal will increase by 30 on every click of view more so this manipulation will make my list view from from expected position.

- 21
- 6