-1

I am developing one app which is based on the webservice and fetch the all data and inflate it into the list with the one image and 3 text view. But it will fetch the all the items which is coming from the web service which is too much time consuming in fetching the data.

I have reached to some of the examples like "pull to refresh" and "View after the list view" when this view is clicks the it loads the data.

I have used the Json and Ksoap2 library for the webservice and responce will be in the JSON form. Thannks in advance.

Arpit Patel
  • 1,561
  • 13
  • 23

2 Answers2

0

I'm not sure that I understand your question. You don't want to fetch all the data at once because it is to much time consuming?

A better way is to inherit from some adapter (BaseAdapter or ArrayAdapter) and override the getView method (it's a general pattern). And inside getView you can fetch data only for one row, instead of all of them.

Basically, getView returns the view for one row of the ListView. You can also cache every row that was displayed via convertView. (here is some good example how to use getView with convertView).

Amer A.
  • 1,025
  • 2
  • 16
  • 22
  • i have already implemented the getView method but and successfully load the all the data from the webservice in my listview. But i wanna add only some data in list and when i press the load more or some other view it will load more 20 items in the list. Like wise i am loading the 200 list items from the webservice and it would be taking around 30-35 seconds to load all the data. i have inflated this all those data into my list once. Need to implement some logic of getting 20-20 items in one time load only. I am not getting how to do that? – Arpit Patel Apr 05 '12 at 18:41
  • The answer is to long so I post a new answer. – Amer A. Apr 07 '12 at 07:57
0

Can I see your getView method? As I understand, getView gets called whenever some row gets visible, so you should implement your logic inside the getview method where you retrive data only for this one particular row. This way your web service gets called only when it is necessary.

But if that isn't what you had in mind, you could do the following. The first time, you fetch data only for 20 items and loads them into some ArrayList. Than you implement OnScrollListener and add the new data to your list (the ArrayList, not the listView) whenever you press load more. So even if you update yout listview with all data, it is loaded from memory, not from your service. Here is a post about OnScrollListener.

Community
  • 1
  • 1
Amer A.
  • 1,025
  • 2
  • 16
  • 22