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 6975127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:19:42+00:00 2026-05-27T17:19:42+00:00

I have Custom List to display image with it’s name like below… public class

  • 0

I have Custom List to display image with it’s name like below…

 public class LazyAdapter extends BaseAdapter {

 private Activity activity;
 private String[] data;
 private static LayoutInflater inflater=null;
 public ImageLoader imageLoader; 

 public LazyAdapter(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 static class ViewHolder{
    public TextView text;
    public ImageView image,yesimage;

 }

 public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    ViewHolder holder;
    if(convertView==null){
        vi = inflater.inflate(R.layout.item, null);
        holder=new ViewHolder();
        holder.text=(TextView)vi.findViewById(R.id.text);;
        holder.image=(ImageView)vi.findViewById(R.id.image);
        holder.yesimage=(ImageView)vi.findViewById(R.id.selectedyes);
        vi.setTag(holder);
    }
    else
        holder=(ViewHolder)vi.getTag();



    holder.text.setText("item "+position);
    holder.image.setTag(data[position]);
    holder.yesimage.setTag(data[position]);

    imageLoader.DisplayImage(data[position], activity, holder.image,holder.yesimage);
    return vi;
}
}

for this list I’m trying to set,

      list=(ListView)findViewById(R.id.list);
      adapter=new LazyAdapter(this, mStrings);//mstrings is array
      list.setAdapter(adapter);
      list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

where as I’m able to get all checked list items using,

      list.setOnItemClickListener(new OnItemClickListener(){

        TextView selected=(TextView)findViewById(R.id.selected);
        final ArrayList<String> years = new ArrayList<String>();

         @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {

            SparseBooleanArray checked = list.getCheckedItemPositions();
                    if(checked.get(arg2))
                    {
                         years.add(""+mStrings[arg2]+"\n");
                    }
                    else
                    {
                     years.remove("    "+mStrings[arg2]+"\n");
                    }

             if(years.size()!=0)
                 selected.setText(years.toString());
             else
             selected.setText("You Have Nothing in Cart");
             }});

but nothing indicates in list that the selected item is checked, it just considers clicked item as selected,Here I cannot use,

    list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, mStrings));
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

Because my list Extends BaseAdapter,

I want to put the checkbox for every row in the list, to ensure that the item is checked once I check that list item, how can I do that…?

  • 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-27T17:19:43+00:00Added an answer on May 27, 2026 at 5:19 pm

    Take CheckBox inside the ViewHolder and implement setOnCheckedChangeListener for each check box.

    for example:

    holder.checkbox = ( CheckBox ) vi.findViewById( R.id.checkbox );
    holder.checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener()
    {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
        {
            if ( isChecked )
            {
                // perform logic
            }
    
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom List which has image field. I have to display the image
I have a custom listPreference I would like to display a list of apps
I have a custom list, and I've added a 'Page Image' field by clicking
I have a list of custom objects List and I would like to update
I have a custom dataGrid that acts more like a 2D list (if that
I have a custom class Contact . I am trying to bind a List<Contact>
I have implemented a custom list view which looks like the twitter timeline. adapter
I have a custom listview which display an image, textview and radio button. I
I have a list view with a custom layout. In the layout I display
I have a list definition with a custom form to display all my list

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.