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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:37:56+00:00 2026-05-26T20:37:56+00:00

I have 5 checkboxes and I have to select multiple checkboxes. I made a

  • 0

I have 5 checkboxes and I have to select multiple checkboxes.

I made a code like this to check check box is checked:

sports=(CheckBox)findViewById(R.id.sports_btn);
sports.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        if (sports.isChecked() == true)
        list.add("4");
    }
}); 

I am adding a value to an array list:

list ArrayList<String> list = new ArrayList<String>();

and I am retrieving the value as string like this:

StringBuilder sb = new StringBuilder();
for(int  i =0; i < list.size(); i++)
{
    for (String str: list)
    {  
        sb.append(str.toString());
        sb.append(",");
    }

}
String sel_cat = sb;

I am getting the string but if two values are selected it is coming like 2,3,
How to remove that last comma? I don’t want the last comma the string has to be like 2,3.

  • 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-26T20:37:56+00:00Added an answer on May 26, 2026 at 8:37 pm
    StringBuilder sb = new StringBuilder();
    sb.deleteCharAt(sb.length()-1) 
    

    Or in your code, use

    StringBuilder sb = new StringBuilder();
    
    for(int  i =0;i<list.size();i++)
    {
        String prefix = "";
        for (String str : list)
        { 
            sb.append(prefix);
            prefix = ",";
            sb.append(str);  
        }
    }
    
    String sel_cat = sb;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want have this ability to select multiple items with checkboxes and delete them
I have a celltable in GWT which have checkboxes, to select multiple checkboxes i
I have a gridview with checkbox inside asp:TemplateField . I wish to select multiple
I would like to select multiple worksheet depending on the userform checkboxes status and
Scenario : I have say 4 check boxes and users can select those checkboxes
I have a select 'All' checkbox that I would like to be bound to
So this is my form (checkbox that allows multiple selections) echoPlease select questions to
I have a page with multiple checkboxes. I need to select all and submit
I have a form with image thumbnails to select with checkboxes for downloading. I
He, I have this page where i have checkboxes next to every item in

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.