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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:25:41+00:00 2026-06-14T13:25:41+00:00

I want to select only one checkbox among 4 checkboxes. I mean, If one

  • 0

I want to select only one checkbox among 4 checkboxes. I mean, If one checkbox is selected others should be disabled. how to achieve this?

  • 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-14T13:25:42+00:00Added an answer on June 14, 2026 at 1:25 pm

    If you use the generic onClick then you could run into future issues with other elements click handlers in your app. I would add android:onClick="onCheckboxClicked" to each CheckBox in your xml file. Then add the method I show below, customized to your id’s etc.

    <CheckBox android:id="@+id/chkBx1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Option 1"
            android:onClick="onCheckboxClicked"/>
    <CheckBox android:id="@+id/chkBx2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Option 2"
            android:onClick="onCheckboxClicked"/>
    <CheckBox android:id="@+id/chkBx3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Option 3"
            android:onClick="onCheckboxClicked"/>
    

    Main Activity:

    public void onCheckboxClicked(View v) {
        CheckBox chk1 = (CheckBox)findViewById(R.id.chkBx1);
        CheckBox chk2 = (CheckBox)findViewById(R.id.chkBx2);
        CheckBox chk3 = (CheckBox)findViewById(R.id.chkBx3);
    
        switch (v.getId()) {
        case R.id.chkBx1:
            if (chk1.isChecked()) {
                chk2.setEnabled(false);
                chk3.setEnabled(false);
            } else {
                chk1.setEnabled(true);
                chk2.setEnabled(true);
                chk3.setEnabled(true);
            }
            break;
    
        case R.id.chkBx2:
            if (chk2.isChecked()) {
                chk1.setEnabled(false);
                chk3.setEnabled(false);
            } else {
                chk1.setEnabled(true);
                chk2.setEnabled(true);
                chk3.setEnabled(true);
            }
            break;
    
        case R.id.chkBx3:
            if (chk3.isChecked()) {
                chk1.setEnabled(false);
                chk2.setEnabled(false);
            } else {
                chk1.setEnabled(true);
                chk2.setEnabled(true);
                chk3.setEnabled(true);
            }
            break;
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select only one radio button but I cant do this. Here
Using VB 6 I want to select path only? Selected Path - C:\Documents and
I want to make user select only one component. Is there a way to
So how can I only allow a user to select only one checkbox? I
Context I want to select only one image and remove borders of other existing
I want to select only the id which has the maximum precedence with the
Using PHP and MySQL, I want to select only 6 rows from table which
I have an array of variables all containing text. I want to select only
i've got an id attribute value for an element. i want to select only
I want to select the second row only from the table. From the ClientUserName

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.