Kindly provide me a sample code which will contain the following:
ListViewin which each list items will have an image icon loaded from an url & 2 textviews .
The image is to be lazily loaded.- Pagination in Android where when the user scrolls vertically & go to the 20th item , a progress dialog will be displayed & in the background a call to the
webeserviceis made to fetch the next set of list items.
I have implemented the Lazy loading part but unable to implement the pagination code.
I got a suggestion to implement the EndlessWrapper class but I am unable to add the logic to the existing code for pagination.
Kindly provide the sample code/logic on how to implement the Pagination on the existing Customised ListView.
Here is the ListView code:
public class LazyListAdapter extends BaseAdapter implements Filterable,
OnClickListener {
int count = 0;
private Activity activity;
private String[] data;
private LayoutInflater inflater = null;
public ImageLoader imageLoader;
public LazyListAdapter(Activity a, String[] d) {
activity = a;
data = d;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader = new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public class ViewHolder {
public TextView textTitle;
public ImageView image;
public ImageView addImage;
}
public View getView(final int position, View convertView,
ViewGroup parent) {
View vi = convertView;
ViewHolder holder;
if (vi == null) {
vi = inflater.inflate(R.layout.list_videos_content, null);
holder = new ViewHolder();
holder.image = (ImageView) vi.findViewById(R.id.iconLine);
holder.textTitle = (TextView) vi.findViewById(R.id.textLine);
holder.addImage = (ImageView) vi.findViewById(R.id.buttonLine);
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
String textStr =tempVec.elementAt(1)
holder.textTitle.setText(textStr);
// Icons bound to the rows.
// Bind the data efficiently with the holder.
holder.image.setTag(data[position]);
holder.addImage.setImageResource(R.id.buttonLine);
imageLoader.DisplayImage(data[position], activity, holder.image);
return vi;
}
}
public Filter getFilter() {
// TODO Auto-generated method stub
return null;
}
public void onClick(View v) {
int i = v.getId();
// TODO Auto-generated method stub
}
i developed something like this, i have an ArrayAdapter wich one handles CustomClass instances, on the construct of the ArrayAdapter i have something like this:
later when user click on this item i do this:
(on my activity who extends ListActivity)
and the method fetchMoreResults(position); execute a web service operation in a thread to retrieve next results…
when operations ends, use a handler to update the ListAdapter and call notifyDataSetChanged();
hope this help you…
add more code by your request
//ItemInfo has all the information i need
MyList list;
//list have a Vector with item information
//int actualPage
//int totalPages
//this is the ListAdapter, when construct them or dataset changes i call syncData with the new data, if there are more items, i add the More… string again, and again… at the bottom is the method who launch the fetchMoreResults method, who invoke a web service to retrive more items.
class ItemList extends ArrayAdapter {