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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:13:29+00:00 2026-06-17T06:13:29+00:00

I cannot retrieve the selected value of the spinner. Can somebody help me? Thanks.

  • 0

I cannot retrieve the selected value of the spinner. Can somebody help me? Thanks.

This is how I retrieve the data. It’s inside the onCreate() method.

mPrefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
SpinnerLang.setSelection(mPrefs.getInt(PREF_SPINNER, 0));

Then I save the Spinner’s value in a button, so when the user selects from the Spinner and clicks the button the selected value will be saved.

//Listening to button event
btnDone.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
    Editor e = mPrefs.edit();
    int Spinnervalue = SpinnerLang.getSelectedItemPosition();
    e.putInt("PREF_SPINNER", Spinnervalue);
    e.commit();
  }
  • 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-17T06:13:30+00:00Added an answer on June 17, 2026 at 6:13 am

    Use a spinner.setOnItemSelectedListener() to store the selected item position in preference

        spinner.setAdapter(mySpinnerAdapter);   
    
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    
            /**
             * Called when a new item is selected (in the Spinner)
             */
            public void onItemSelected(AdapterView<?> parent,
                View view, int position, long id) {
                mPrefs.edit().putInt("PREF_SPINNER", position).commit();
            }
    
            public void onNothingSelected(AdapterView<?> parent) {
              // Do nothing.
            }
        }); // (optional)
    
        //UPDATE - When you are using a button onCLick()
        // to set the spinner selection:
        button.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                spinner.setSelection(mPrefs.getInt("PREF_SPINNER", 0));
    
            }
        });
    
    
    
         // set the spinner selected item from preference after 
         // spinner.setAdapter(mySpinnerAdapter);
         // -or it will default to the first item
     //    spinner.setSelection(mPrefs.getInt(PREF_SPINNER, 0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had Repeater which bind method this method retrieve data from data base by
I have a dojo (1.8.1) DataGrid where I cannot retrieve all the selected items
How can I retrieve the item that is selected in a WPF-treeview? I want
While it is clear we cannot retrieve a list of installed applications on iOS,
I have a really frustrating issue where I cannot retrieve any of the headers.
trying to retrieve the id column of records that have their checkboxes selected in
I am trying to retrieve data in a JSON object (which I have validated
I'm trying to retrieve a boolean value from one of two member functions. I
I am creating an application that can get text from the selected rectangle on
I cannot retrieve multiple files in my php code from $_FILES. Here is the

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.