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

  • SEARCH
  • Home
  • 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 8315013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:00:59+00:00 2026-06-08T21:00:59+00:00

This CheckBox in a ListView is driving me nuts. I’ve searched a lot about

  • 0

This CheckBox in a ListView is driving me nuts. I’ve searched a lot about this on StackOverflow but I’m not able to fix this.

The problem is that I’m having a custom adapter for ListView in which I’m inflating the CheckBox.

Here’s the code:

public class settingadapter extends BaseAdapter{

    private Activity recievedactivity;

    private String[] recieveddescription;
    private String[] recusername;
    private String allitems="";
    private String[] itemchecked;

    private static LayoutInflater inflator=null;


    public settingadapter(Activity recactivity,String[] username, String[] recdescription ){
        recievedactivity=recactivity;
        recusername=username;
        recieveddescription=recdescription;

        inflator=(LayoutInflater)recievedactivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);



    }
    public settingadapter(Activity recactivity,String[] username, String[] recdescription ,String all){
        recievedactivity=recactivity;
        recusername=username;
        recieveddescription=recdescription;
        allitems=all;
        inflator=(LayoutInflater)recievedactivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


    }


    public int getCount() {
        // TODO Auto-generated method stub
        return recusername.length;
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
    static class ViewHolder{
        TextView usernameTextView;
        TextView statusTextView;
        CheckBox checkView;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        final ViewHolder viewHolder;

        if(convertView== null)
        {
            viewHolder=new ViewHolder();

            convertView=inflator.inflate(R.layout.item, null);

            viewHolder.usernameTextView=(TextView)convertView.findViewById(R.id.textView1);
            viewHolder.statusTextView=(TextView)convertView.findViewById(R.id.text);
            viewHolder.checkView=(CheckBox)convertView.findViewById(R.id.checkBox1);





            convertView.setTag(viewHolder);


        }else{
            viewHolder=(ViewHolder)convertView.getTag();
        }
            viewHolder.usernameTextView.setText(recusername[position]);
            viewHolder.statusTextView.setText(recieveddescription[position]);
             //Add listener to the checkbox


            System.out.println("testing alpha"+recusername[position]);

            if(allitems.equals("All")){
                viewHolder.checkView.setChecked(true);
            }
            else if (allitems.equals("---Select User---")){
                viewHolder.checkView.setChecked(false);
            }
            else
             return convertView;  
            //image.setBackgroundResource(R.drawable.check);



            return convertView;



    }

}

Now in this how do I get which CheckBox is clicked and how can I get the corresponding text also?

  • 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-06-08T21:01:00+00:00Added an answer on June 8, 2026 at 9:01 pm

    Please check these codes

    Here in ans the person has added onclick event and getting the tag.
    Android how to identify item in listview with checkbox

    Same code without onclick for checkboxes
    http://windrealm.org/tutorials/android/listview-with-checkboxes-without-listactivity.php

    hope it will help you 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my html.beginform I have this checkbox that I want to persist. I'm not
Hello I've already read quite a bit about the CheckBox/ListView problems in Android. So
I have a ListView Control in WindowsForm and also this Listivew has a checkBox
Using the following to populate my ListView with checkbox-supported list: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, new
I have a problem with listview which list item contain a checkbox. When i
I have a checkbox in my ListView row which looks like this. =========================================== [CheckBox]
I am using ListView with CheckBox . I have selected only one CheckBox but
i am use this for setting checkbox in listview i have follow all step
I am having problems posting this multi checkbox data with ajax. <?php foreach($_SESSION['contacts'] as
This is my code: <CheckBox android:id=@+id/sprint_checkbox android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/sprint_game /> <CheckBox android:id=@+id/marathon_checkbox android:layout_width=fill_parent android:layout_height=wrap_content

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.