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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:08:35+00:00 2026-06-07T00:08:35+00:00

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

  • 0

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"
        android:text="@string/marathon" />

    <CheckBox
        android:id="@+id/never_ending_checkbox"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/never_ending" />

What i want to do is “detect” when one of these is checked and then set the other two to “disable”, so the user can select only one at time.
I tried to use the “.setOnCheckedChangeListener”, but i can’t do that, can someone help me with some code?
Thanks a lot guys!

  • 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-07T00:08:37+00:00Added an answer on June 7, 2026 at 12:08 am

    This is the way you are notified about checked changes:

    CheckBox check = findViewById(R.id.sprint_checkbox);
    check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                //do stuff
    
            }
        });
    

    You can also let your activity implements the OnCheckedChangeListener interface and then:

    CheckBox check1 = findViewById(R.id.sprint_checkbox);
    CheckBox check2 = findViewById(R.id.marathon_checkbox); 
    CheckBox check3 = findViewById(R.id.never_ending_checkbox);
    
    check1.setOnCheckedChangeListener(this);
    check2.setOnCheckedChangeListener(this);
    check3.setOnCheckedChangeListener(this);
    

    Overriding the interface method:

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch(buttonView.getId()){
                   case R.id.sprint_checkbox:
                     //do stuff
                   break;
                   case R.id.marathon_checkbox:
                     //do stuff
                   break;
                   case R.id.never_ending_checkbox:
                    //do stuff
                   break;
    
                }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The main.xml file code: <TableRow android:id=@+id/TableRow01 android:layout_width=wrap_content android:layout_height=wrap_content> <TextView android:text=User android:id=@+id/TextView01 android:layout_width=wrap_content android:layout_height=wrap_content></TextView> <EditText
In my xml i have an edittext element like this <EditText android:id=@+id/hrvalue android:layout_width=wrap_content android:layout_height=wrap_content
I use this code to determine checkbox width and height: var chk = $('input[type=checkbox]:first');
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
This is the code section from inno setup.My intention is to make two Checkbox
I have the following code: function toggleChecked(status) { $(.checkbox).each( function() { $(this).attr(checked,status); }) }
I am doing a preferenceScreen with this xml code: <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android android:orderingFromXml=true> <PreferenceCategory android:key=pref1
I am re using code mentioned at tutorial http://vikaskanani.wordpress.com/android-custom-gallery-and-instant-upload-project/ In this project, How can
Given this code, how do I get the values from the checkbox- and textpreference

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.