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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:21:00+00:00 2026-05-30T07:21:00+00:00

In my project I am displaying the checkboxes dynamically . But I want to

  • 0

In my project I am displaying the checkboxes dynamically. But I want to get the id values of all the checkboxes that are selected. In my application the user will select multiple checkboxes and I need to store those selected checkboxes id’s in an arraylist. How can I get the selected checkboxes id’s?

My Code:

 public View getView(int position, View convertView, ViewGroup parent) 
{
  View view = convertView;
  try
  {
  if (view == null) 
   {
    LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = vi.inflate(R.layout.list_item1, null); 
    }
    final UserBO listItem = mList.get(position);            
    if (listItem != null) 
      {

    Rl = (LinearLayout)findViewById(R.id.chklnlayout);

    ArrayList<UserBO> mList1;

    CheckBox[] cbs = new CheckBox[20]; 

    for(int k=0; k<list.size(); k++)
    { 
     System.out.println("list in for loop"+list.get(0));
     arr = list.get(k);
     cbs[k] = new CheckBox(getContext());
     Rl.addView(cbs[k]);
     cbs[k].setText((CharSequence) arr.get(2));
     cbs[k].setTextColor(Color.parseColor("#000000"));  
    } 

   }
}
catch(Exception e){
  String err = (e.getMessage()==null)?"hii":e.getMessage();
  Log.e("sdcard-err2:",err);  
}
return view;
}

Please help me regarding this….Thanks in Advance

  • 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-30T07:21:01+00:00Added an answer on May 30, 2026 at 7:21 am

    In your code for loop,

    Write this line,

    cbs[k].setId(k);
    

    Now implements OnClickListener in your activity

    in

    @Override
    public void onClick(View v)
    {
    int checkBoxId  = v.getId();    
    }
    

    or something like,

    @Override
        public void onClick(View v)
        {
            // Perform action on clicks, depending on whether it's now checked
            if (((CheckBox) v).isChecked()) {
                Toast.makeText(Activity.this, "Selected CheckBox ID" + v.getId(), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(Activity.this, "Not selected", Toast.LENGTH_SHORT).show();
            }
    }
    

    And let me know what happen..

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

Sidebar

Related Questions

I am developing a project in which i'm displaying certain checkboxes to user that
I running a rails project and I am displaying a textfield that can often
I'm attempting to modify an inherited project that has a convoluted process of displaying
I am trying to run my application but it is displaying error in the
I'm working on a college project to allow a user select a csv file
In android project/application,I want to display screen2 containing listview when the list item of
Working on a game project that involves a scripting language that I want to
When I run project in IIS, after displaying home page it will not allow
I have a console application project in C# 2.0 that needs to write something
I have a project that has a requirement of displaying map data in offline

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.