Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3431806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:22:18+00:00 2026-05-18T07:22:18+00:00

Kindly provide me a sample code which will contain the following: ListView in which

  • 0

Kindly provide me a sample code which will contain the following:

  1. ListView in which each list items will have an image icon loaded from an url & 2 textviews .
    The image is to be lazily loaded.
  2. 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 webeservice is 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
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:22:19+00:00Added an answer on May 18, 2026 at 7:22 am

    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:

    //add pagination item
           if(list.getActualPage()<list.getTotalPages()){
                add("More...");
            }
    

    later when user click on this item i do this:
    (on my activity who extends ListActivity)

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        if(getListAdapter().getItem(position) instanceof String){
            v.setEnabled(false);
            ((ProgressBar)v.findViewById(R.id.listItemMoreProgressBar)).setVisibility(View.VISIBLE);
            fetchMoreResults(position);
        }else{
            //launch item information
            Intent intent = new Intent();
            intent.setClass(ListItemActivity.this, ItemInfoActivity.class);
            startActivity(intent);
        }
    }
    

    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 {

        private Context ctx;
        private String moreText = "More...";
    
        public ItemList(Context context, int textViewResourceId, List<Object> objects) {
            super(context, textViewResourceId, objects);
            this.ctx = context;
    
            //add pagination item
            if(list.getPaginaActual()<list.getTotalPaginas()){
                add(moreText);
            }
        }
    
        //call this method when adding more info into the list
        public void syncData( List<ItemInfo> newData ){
            remove(moreText);
            for(Object o : newData){
                add(o);
            }
            if(list.getPaginaActual()<list.getTotalPaginas()){
                add(moreText);
            }
        }
    
        ItemViewHolder itemHolder;
        MoreItemsViewHolder moreItemsHolder;
    
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = LayoutInflater.from(ctx);
            if( getItem(position) instanceof String ){
                moreItemsHolder = new MoreItemsViewHolder();
                if(convertView == null || convertView.getTag() instanceof ItemViewHolder){
                    convertView = inflater.inflate(R.layout.list_item_more, parent, false);
                }
                moreItemsHolder.title = ((TextView)convertView.findViewById(R.id.listItemMoreFirstLine));
                moreItemsHolder.title.setText(getItem(position).toString());
                convertView.setTag(moreItemsHolder);
            }else{
                itemHolder = new ItemViewHolder();
                if(convertView == null || convertView.getTag() instanceof MoreItemsViewHolder){
                    convertView = inflater.inflate(R.layout.lista_propiedades, parent, false);
                    convertView.setTag(itemHolder);
                }
                itemHolder.title = ((TextView)convertView.findViewById(R.id.listItemFirstLine));
                itemHolder.description = ((TextView)convertView.findViewById(R.id.listItemSecondLine));
                itemHolder.title.setText( ((ItemInfo)getItem(position)).getTitulo() );
                itemHolder.description.setText( ((ItemInfo)getItem(position)).getDescripcion() );
    
            }
            return convertView;
        }
    
    }
    
    static class ItemViewHolder{
        TextView title;
        TextView description;
    }
    
    static class MoreItemsViewHolder{
        TextView title;
    }
    
    
    
    
    
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        if(getListAdapter().getItem(position) instanceof String){
            v.setEnabled(false);
            ((ProgressBar)v.findViewById(R.id.listItemMoreProgressBar)).setVisibility(View.VISIBLE);
            fetchMoreResults(position);
        }else{
            //launch item info
            Intent intent = new Intent();
            intent.setClass(MyActivity.this, ItemInfoActivity.class);
            startActivity(intent);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kindly point towards theory/material to read for understanding colors and what makes a good
I need to get substed drive letter in Perl. Could anyone kindly help me?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.