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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:02:18+00:00 2026-06-15T13:02:18+00:00

I have a spinner like this: // Spinner 1 final Spinner plan = (Spinner)

  • 0

I have a spinner like this:

// Spinner 1


final Spinner plan = (Spinner) dialog.findViewById(R.id.spinner1);
strings = getResources().getStringArray(R.array.paymentplan);
sAdapter = new SpinnerAdapter(this,
        android.R.layout.simple_spinner_item, strings);
sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
plan.setAdapter(sAdapter);

// plan.setAdapter(spinner1Adapter);
plan.setSelection(prefsDisplay.getInt("spinnerSelection1", 0));
plan.setOnItemSelectedListener(new MyOnItemSelectedListenerPlan());

When user clicks, I want it to save state:

  public void onClick(View v) {
                Editor editor2 = prefsPlan.edit();
                int selectedPosition1 = plan.getSelectedItemPosition();
                editor2.putInt("spinnerSelection1", selectedPosition1);
                editor2.commit();


}

It saves the position in SharedPref, but the spinner goes back to default. Anyone see something here?

  • 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-15T13:02:19+00:00Added an answer on June 15, 2026 at 1:02 pm

    you are storing spinnerSelection

    editor1.putInt("spinnerSelection", selectedPosition);
    

    an accessing spinnerSelection1

    prefsDisplay.getInt("spinnerSelection1", 0)
    

    make them consistent.

    Update

    when you are accessing plan.getSelectedItemPosition(). then spinner is visible? I guess NO.

    try to put a public variable for selected position. And update selected position in your MyOnItemSelectedListenerPlan. And then store that position in shared preferences. I guess it solve your problem.

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

Sidebar

Related Questions

I have a spinner set up like this: ArrayAdapter<String> states = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
I have a array list like this: private ArrayList<Locations> Artist_Result = new ArrayList<Location>(); This
I have populated a spinner with some data, like this: adapter = newSpinAdapter(this,com.Orange.R.layout.spinnerrowlist,spinnerInfo); adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
I have created a Spinner and ArrayAdapter as follows: Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
My spinner coding is something like this: assetSpinner = (Spinner) findViewById(R.id.editAsset); assetAdapter = ArrayAdapter.createFromResource(
I have loaded data to normal list view from JSON array like this JSONArray
I have spinner and code android.R.layout.simple_spinner_dropdown_item . But I get weird height like this:
I would like to have a Spinner updated upon an onTap event in my
Hi I have a spinner for which I would like to change its entry.
I have an MessageBox and init is a ActivityIndicator like spinner . So to

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.