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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:26:54+00:00 2026-05-27T05:26:54+00:00

When my UI is recreated on orientation change, I use super.onCreate(savedInstanceState) and getLastNonConfigurationInstance() to

  • 0

When my UI is recreated on orientation change, I use super.onCreate(savedInstanceState) and getLastNonConfigurationInstance() to access custom data I stored to fill the dynamic parts of my layout.

I have a RadioGroup which has two RadioButtons and is already defined in the XML file. The XML automatically makes the first one selected.

When an orientation change happens and the SECOND RadioButton is selected, everything seems to work fine; the second RadioButton is still selected in the UI.

But RadioGroup.getCheckedRadioButtonId() says the first RadioButton is selected. And I actually WANT the first one to be selected. But nothing changes when I call rb1.setChecked(true) – second one still shown as selected, and still the RadioGroup tells me the first one is selected (now it would make sense, but it’s not shown).

This is REALLY strange behavior, does anyone have tips?

(edit)
Parts of my code:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.itemselected);
    (...)
    radioGroupServingType = (RadioGroup) findViewById(R.id.radioGroupServingType);
    (...)

    RadioButton radioOwnServing = (RadioButton) findViewById(R.id.radioOwnServing);
    RadioButton radioUseServing = (RadioButton) findViewById(R.id.radioUseServing);

    radioOwnServing.setOnClickListener(this);
    radioUseServing.setOnClickListener(this);

    //FIXME WTF
    Log.d("", radioOwnServing.isChecked()+"/"+radioUseServing.isChecked()+" own/use checked");
    radioOwnServing.setChecked(true);
    Log.d("", radioOwnServing.isChecked()+"/"+radioUseServing.isChecked()+" own/use checked");

If I select radioUseServing in the UI and change the orientation, the log says true/false own/use checked both times – although radioUseServing is shown as selected in the UI.

By the way, logcat also outputs

W/asset(4040): deep redirect failure from 0x0103003e => 0x02060007, defStyleAttr=0x0101007e, defStyleRes=0x0103001a, style=0x00000000

when changing the orientation, sometimes multiple times. I haven’t found anything with google on what that means.

  • 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-27T05:26:54+00:00Added an answer on May 27, 2026 at 5:26 am

    I already spoke with you on IRC, but I believe that if you get the view, and post a runnable to it that will call .setChecked(), this will in effect cause the setChecked call to occur at the proper time, and thus avoiding having called setChecked before the view hierarchy was ready for it.
    Something like this:

    final View myRadioButton  = findViewById(R.id.myradiobutton); 
    myRadioButton.post(
        new Runnable() {
            @Override
            public void run() { myRadioButton.setChecked(true); }
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity that shouldn't be recreated after an orientation change. I added
I use codefirst and I use Elmah. I recreated every time the database, you
I am working on a dynamic report where charts need to be recreated on
I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes
I have been using Locale for app language which on orientation change needs to
I want to change the size of video if I change the orientation mode
The basis: Activity - recreates(onCreate-onDestroy) on each orientatin change View consists of ViewFlipper with
In Android, when the screen orientation changes (between landscape and portrait) the onCreate method
I ran across some code recently at work (recreated to be similar to what
I've noticed in more than one SQLite tutorial that the table is recreated 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.