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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:38:44+00:00 2026-05-15T01:38:44+00:00

I have a preferences activity where I can change the language and the theme

  • 0

I have a preferences activity where I can change the language and the theme of my application. From there I return to the previous activity via the Back key, and I want to recreate the activity.

I’ve managed to do that by reinitializing the layout in onResume and also calling onRestoreInstanceState from there. All the views are restored properly, with checkboxes checked if needed, edittexts filled with texts I left there previously.

But I also have a button which is initially disabled, and becomes enabled only when a radiobutton is checked. The problem with it is the following: I check the radiobutton, the button becomes enabled. Then I go to settings, change the theme there, and return to the first activity. When I arrive there, the radiobutton is restored as checked, but the button is disabled.

So it seems that the enabled/disabled state isn’t being saved into the bundle, which seems counterintuitive. And I haven’t found any code in the Android source that does this, too. Am I missing something, or do I have to write my own code for that?

EDIT: BTW, state is saved only for the views which have ids. And that button does have one, I guarantee that 🙂

  • 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-15T01:38:45+00:00Added an answer on May 15, 2026 at 1:38 am

    They key here is to see what is actually enabling the button and to make sure that is consistent on every access to the application.

    From your statement:

    But I also have a button which is initially disabled, and becomes enabled only when a radiobutton is checked.

    it appears that you have a listener on the radiobutton which enables the button. From this, I gather that the button is initially disabled, meaning that you’ll have to change that every time you run the activity.

    Your options are as follows:

    • Have the radiobutton set some sort of global preference which is checked in onResume, enabling the button if necessary
    • When the radiobutton is checked, change the global settings (or perhaps the GUI settings) to one in which the button is enabled. That can stay forever until the radiobutton is unchecked again.
    • Saving the enabledness in onSaveInstanceState as you mention

    It is difficult to tell which is most appropriate because you haven’t mentioned the context of the use case, but I would avoid sending it through in the bundle unless it is a very occasionally used activity. It makes a lot of sense to keep track of the radiobutton setting by either storing it or changing the view until further notice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.