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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:15:49+00:00 2026-06-09T07:15:49+00:00

I think i can simplify the problem domain. Basically i have set the preference

  • 0

I think i can simplify the problem domain. Basically i have set the preference activity to have button set to on. The problem arises when i click off and then come back to the preference and its still on i tried to create a boolean switch but form some reason it doesnt work. The code is posted below.

solution
I think the solution is to fix the problem of when the user clicks on the toggle button and turns it off since I have set clickable to true in the public void Oncreate method. Every time the user goes back to the preference activity the value is set to on. I think a condition which overrides that parameter would fix my problem.

prefs = getSharedPreferences(prefName, 0 );

SharedPreferences.Editor editor = prefs.edit();

if (twitter.isChecked() == true)
{
    onoffTwitter = true;
    editor.putBoolean(TWITTER_KEY, true);
    onoffTwitter = true;
}

if (twitter.isChecked() == false)
{
    onoffTwitter = false;
    editor.putBoolean(TWITTER_KEY, false);

    onoffTwitter = false;
}

Toast.makeText(getBaseContext(), 
               "was the twitter checked" + twitter.isChecked(), 
               Toast.LENGTH_SHORT).show();

editor.commit();

And this code is from another activity which hides the button.

SharedPreferences prefs = getSharedPreferences(prefName, 0);
buttonStatus = prefs.getBoolean(TWITTER_KEY, false); 
Log.e(LOGS, "What is the value for the twitter feed" + buttonStatus);

Toast.makeText(AndroidGUIActivity.this,
               " What is the value for the twitter feed" + buttonStatus,
               Toast.LENGTH_SHORT).show();

if (buttonStatus==false) twitter.setVisibility(View.GONE);

I believe I can fix this by setting the initial value of the togglebutton in the xml file.

  • 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-09T07:15:53+00:00Added an answer on June 9, 2026 at 7:15 am

    The problem was I was not passing the preference value to the twitter but so it wasn’t storing the value.

    prefs = getSharedPreferences(prefName, 0 );
             buttonStatus = prefs.getBoolean(TWITTER_KEY, true); 
             Log.e(LOGS, "What is the value for the timer feed" + buttonStatus);
    
    
            twitter.setChecked(buttonStatus);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have (or so I think!) a simple problem. I will greatly simplify my
I've got a pretty minor problem that I think can be resolved by re-thinking
What I can think of is: Algo: Have a hash table which will store
One method which I can think of is to reverse the list and then
Sorry for the title, I really couldn't think of how to simplify this problem.
I have an odd problem that I just can't seem to diagnose, and it
Hi I'm trying to simplify this code but can't think which way to do
my mind is blank and I can't think of the solution... I have the
Hi all I am having some problems that I think can be attributed to
I can think of lots of ways to do this on my own, but

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.