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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:21:44+00:00 2026-05-25T17:21:44+00:00

In my Application i am using Spinner which contain 1 to 60 items from

  • 0

In my Application i am using Spinner which contain 1 to 60 items from which user have to select anyone of them.My problem is that when user again call the Activity which contain spinner, user can able to see his previously selected item as the default value of spinner.
I have try to use the spineer.setselection() but i am not able to get.
so if anyone have any ideal about this then please give some hint to solve my problem.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ViewGroup viewgroup = (ViewGroup) findViewById(R.id.myprofilelinear);
    ViewGroup.inflate(this, R.layout.spinner,
            viewgroup);

    LoadUI();
}
public void LoadUI()
{
    imgtoggle = (ImageView) findViewById(R.id.btntoggle);
    imgtoggle.setOnClickListener(this);
    String param=JsonDataProcessor.MYPROFILELIST.get(0).getIsTracking();
    if(param.equalsIgnoreCase("True"))
    {
        imgtoggle.setImageResource(R.drawable.on_button);
    }
    else
    {
        imgtoggle.setImageResource(R.drawable.off_button);
    }

    btnsave = (Button)findViewById(R.id.btnSavechanges);
    btnsave.setOnClickListener(this);

    String[] s = new String[60];
    int i;
    for (i = 0; i < 60; i++) {
        s[i] = Integer.toString(i+1);
    }

     spin = (Spinner) findViewById(R.id.TimeSpinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(TimeSpin.this,
            android.R.layout.simple_spinner_item, s);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(adapter);

}
  • 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-25T17:21:44+00:00Added an answer on May 25, 2026 at 5:21 pm

    You should Ignite OnItemselectedListener for this and set the selected value in Spinner

    Check this Code :

        boolean flag_default_country=false;
    
        spin_country.setOnItemSelectedListener(new OnItemSelectedListener() {
    
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                // TODO Auto-generated method stub
                    for (int i = 0; i < s.length; i++) {
                        if (flag_default_country == false) {
                            if (s[i].toString().equalsIgnoreCase("US")) {
                                spin_country.setSelection(i);
                                flag_default_country = true;
                            }
                        }
                    }
                }
    
            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub
            }
        });
    

    spin_country is Spinner Object

    first initialize the flag_default_country to false , then check for the String value selected by User that was stored in Some values. if the Array value at i’th position equals to the user selected value it will set the value at i in the Spinner.

    For Saving the user selected value you can use the Shared preference.

    Check this link for Shared Preference.

    Let me know if you find any difficulty.

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

Sidebar

Related Questions

I have a Php application using stream_socket_client(), to get data through tcp from a
I have developed an application using J9 that runs in windows mobile. but now
im making an android application which requires a user to register using a form
I am developing an android application in which I am populating a spinner from
I made one application that using the spinner in it. in my application client
I am using a android spinner to select among city names. The problem is
I have Spinners that I am using in my application. They are working fine
i am developing an application using c#.net in which i need that if a
I have a web application using ASP.NET 2.0 and I want to know if
I am developing an application using MVC Preview 5. I have used typed views.

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.