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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:53:04+00:00 2026-06-01T18:53:04+00:00

i’m working on custom radio button. it works fine(as it is defined in options.xml)

  • 0

i’m working on custom radio button. it works fine(as it is defined in options.xml) but when i switch from options.xml to main.xml, it turns default, means it is no more highlighted. it should work like until i press it it should not turn to default.. here is radiobutton_selector.xml

        <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/radio_down" android:state_checked="true"/>
        <item android:drawable="@drawable/radio" android:state_checked="false"/>
        </selector>

i’m using these in options.xml to call radio button settings.

        <RadioGroup
            android:id="@+id/sound"
            android:layout_width="150dp"
            android:layout_height="100dp"
            android:layout_gravity="right"
            android:layout_marginRight="0dp"
            android:layout_marginTop="50dp"
            android:orientation="vertical"
            android:padding="0dp" >

            <RadioButton
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:button="@drawable/radiobutton_selector"
                android:id="@+id/on"
                />

            <RadioButton
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:button="@drawable/radiobutton_selector"
                android:id="@+id/off"
                />
        </RadioGroup>

Please help me to figure out the issue. 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-06-01T18:53:06+00:00Added an answer on June 1, 2026 at 6:53 pm

    You can do like this for your RadioGroup.
    you need to save which radio Button you have selected ,for that you can use one variable like below.

    int check_radio=-1;
    public static final int RADIO_BUTTON_ON=1;
    public static final int RADIO_BUTTON_OFF=2;
    
           mRadioGroup
                    .setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
                        @Override
                        public void onCheckedChanged(RadioGroup group,
                                int checkedId) {
    
                            switch(checkedId){
    
                                                case R.id.on:
                                                //Radio Button on is True
                                                check_radio=RADIO_BUTTON_ON;
                         SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
                         SharedPreferences.Editor editor = settings.edit();
                          editor.putInt("RadioButton", RADIO_BUTTON_ON);
                         // Commit the edits!
                         editor.commit();
                                                break;
                                               case R.id.off:
                                              //Radio Button off is True
                                               check_radio=RADIO_BUTTON_OFF;
                           SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
                         SharedPreferences.Editor editor = settings.edit();
                          editor.putInt("RadioButton", RADIO_BUTTON_OFF);
                         // Commit the edits!
                         editor.commit();
                                              break;
                        }
                    });
    

    Now whey your Activity ‘s Resume you can check one condition like below.
    Get Value from SharedPrefrence Like below code;

       //If you have save your value in SharedPrefrence it will return your stored int value.
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
       check_radio = settings.getInt("RadioButton", -1);
    
    
      if(check_radio==RADIO_BUTTON_ON){
         mRadioOn.setChecked(true);
      }else if(check_radio==RADIO_BUTTON_OFF){
        mRadioOff.setChecked(true);
      }
    

    you can use SharedPreferences by below step

       public static final String PREFS_NAME = "MyPrefsFile";
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.