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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:31:12+00:00 2026-05-28T03:31:12+00:00

I want to allow the user to select a website from Preferences in my

  • 0

I want to allow the user to select a website from Preferences in my Android app.
But when user choose a website from preferences list , imagebutton’s image and its loadurl code must change.The image and loadurl should then remain the same even if the app closes.

now i ve preferences menu and values.but how can i change imagebutton’s image and its url i dont know.
thank you.

  • 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-28T03:31:12+00:00Added an answer on May 28, 2026 at 3:31 am

    Just save the info to shared preferences, then use an if statement to load the shared preferences. as in

    if (preferences == websiteOne){
    //load shared preferences  for websiteOne here
    } else {
    // load shared preferences for websiteTwo here
    }
    

    If you have more than two websites, you can set up a switch/case

    EDIT

    switch (website){
    case websiteOne:
    // shared preferences for websiteOne
    imageView.setImageResource(imageResourceFromSharedPreferences);
    url.setText(urlFromSharedPreferences)
    break;
    case websiteTwo:
    // shared preferences for websiteTwo
    break;
    }
    

    Do that for all 10 websites

    EDIT 2

    to set up a default sharedPreferences, in your onCreate() of an early activity, you can use

    data = getSharedPreferences(filename, 0);
    SharedPreferences.Editor e = data.edit();
            e.putString("website", websiteVariable);
            e.commit();
    

    Do the same for the URL, and add these two variables SharedPreferences data; and public static String filename = "fileName";

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

Sidebar

Related Questions

I want to allow a user to select an image from their local filesystem
In my iPhone app, I want to allow the user to draw image by
I want to allow user to select range of items in my unordered list
I want to show a dialog that will allow the user to select a
I want to allow the user to select the icon that appears for their
I want a to user a DateChooser to allow a user to select a
I am attempting to write a custom control. I want to allow its user
I want to make a panel and allow user to select a template and
I've got a select box with some options. I want to allow a user
I have a UILabel, but how can I allow the user to select a

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.