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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:59:02+00:00 2026-06-04T17:59:02+00:00

I have an options page with 5 spinners. As the user is logged in

  • 0

I have an options page with 5 spinners. As the user is logged in and modifying their account options, I would like the spinner to load the user’s choice for the spinner. At the moment each spinner loads the first value in it’s adapter ‘Please Select’. That’s fine if the server is checked and the user hasn’t made a choice yet – but I’d like that to be decided based on the obvious conditions.

Is there a good way to do this? I’ve just finished the code for sending the spinner choices to the server and storing them alongside the appropriate user. So I know I need different PHP queries, that’s no problem. But how do I set the visible value for the spinner inside onCreate?

    ageSpinner = (Spinner) findViewById(R.id.ageSpinner);
    ageAdapter = ArrayAdapter.createFromResource
    (this, R.array.ageArray, android.R.layout.simple_spinner_item);
    ageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ageSpinner.setAdapter(ageAdapter);
    ageSpinner.setTag("age");
    ageSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

    eduSpinner = (Spinner) findViewById(R.id.eduSpinner);
    eduAdapter = ArrayAdapter.createFromResource
    (this, R.array.eduArray, android.R.layout.simple_spinner_item);
    eduAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    eduSpinner.setTag("edu");
    eduSpinner.setAdapter(eduAdapter);
    eduSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

    maritalSpinner = (Spinner) findViewById(R.id.maritalSpinner);
    maritalAdapter = ArrayAdapter.createFromResource
    (this, R.array.maritalArray, android.R.layout.simple_spinner_item);
    maritalAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    maritalSpinner.setTag("marital");
    maritalSpinner.setAdapter(maritalAdapter);
    maritalSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

    nationalitySpinner = (Spinner) findViewById(R.id.nationalitySpinner);
    nationalityAdapter = ArrayAdapter.createFromResource
    (this, R.array.nationalityArray, android.R.layout.simple_spinner_item);
    nationalityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    nationalitySpinner.setTag("nationality");
    nationalitySpinner.setAdapter(nationalityAdapter);
    nationalitySpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());

public class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
            View view, int pos, long id) {

        if (pos != 0) {

            param.add(new BasicNameValuePair(parent.getTag().toString(), 
                    parent.getItemAtPosition(pos).toString()));
        }
    }

    public void onNothingSelected(AdapterView parent) {
        // Do nothing.
    }
}
  • 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-04T17:59:03+00:00Added an answer on June 4, 2026 at 5:59 pm

    I used EditTexts linked to a CustomDialog to display the data. It works much better. I have AsyncTasks that load the data into the uneditable EditTexts onCreate and onSubmit. Here’s some related code:

        ageEditText = (EditText) findViewById(R.id.ageEditText);
        ageEditText.setOnClickListener(fieldListener);
        ageEditText.setId(0);
        educationEditText = (EditText) findViewById(R.id.educationEditText);
        educationEditText.setOnClickListener(fieldListener);
        educationEditText.setId(1);
        maritalEditText = (EditText) findViewById(R.id.maritalEditText);
        maritalEditText.setOnClickListener(fieldListener);
        maritalEditText.setId(2);
        backgroundEditText = (EditText) findViewById(R.id.backgroundEditText);
        backgroundEditText.setOnClickListener(fieldListener);
        backgroundEditText.setId(3);
        incomeEditText = (EditText) findViewById(R.id.incomeEditText);
        incomeEditText.setOnClickListener(fieldListener);
        incomeEditText.setId(4);
        partyEditText = (EditText) findViewById(R.id.partyEditText);
        partyEditText.setOnClickListener(fieldListener);
        partyEditText.setId(5);
    

    public OnClickListener fieldListener = new OnClickListener() {
    public void onClick(View v) {
    FragmentManager fm = getSupportFragmentManager();
    switch (v.getId()) {
    case (0) :

            ChooseDialog ageDialog = new ChooseDialog("Age", ageEditText, act);
            ageDialog.show(fm, "fragment_edit_name");
                break;
            case (1) :
            ChooseDialog educationDialog = new ChooseDialog("Education", educationEditText, act);
    
            educationDialog.show(fm, "fragment_edit_name");
                break;
            case (2) :
            ChooseDialog maritalDialog = new ChooseDialog("Marital", maritalEditText, act);
    
            maritalDialog.show(fm, "fragment_edit_name");
                break;
            case (3) :
            ChooseDialog backgroundDialog = new ChooseDialog("Background", backgroundEditText, act);
    
            backgroundDialog.show(fm, "fragment_edit_name");
                break;
            case (4):
                ChooseDialog incomeDialog = new ChooseDialog("Income", incomeEditText, act);
    
                incomeDialog.show(fm, "fragment_edit_name");
                    break;
            case (5):
                ChooseDialog partyDialog = new ChooseDialog("Income", partyEditText, act);
    
                partyDialog.show(fm, "fragment_edit_name");
                    break;
    
            }
    
        }
    };
    
    private void submit() {
        params = new ArrayList<NameValuePair>();
        getButtons();
        params.add(new BasicNameValuePair("age", ageEditText.getText().toString()));
        params.add(new BasicNameValuePair("marital", maritalEditText.getText().toString()));
        params.add(new BasicNameValuePair("background", backgroundEditText.getText().toString()));
        params.add(new BasicNameValuePair("education", educationEditText.getText().toString()));
        params.add(new BasicNameValuePair("income", incomeEditText.getText().toString()));
        params.add(new BasicNameValuePair("sex", sexString));
        params.add(new BasicNameValuePair("employment", empString));
        params.add(new BasicNameValuePair("party", partyEditText.getText().toString()));
    
        params.add(new BasicNameValuePair("user", dbHandler.getUserDetails().get("email").toString()));
        DemoTask demoTask = new DemoTask(act, params);
        demoTask.execute();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with some user selectable options and a button that, when
I have an ASP.Net page, which displays a list of options to the user.
I'm building a theme options page for my WordPress theme and I would like
I am making a game and I have an options page which turns the
Hello I have a word press options page and I want to make it
I have a download page where there are 3 download options: Word, Zip, and
I have a page with an image, and two options: Show image full browser
I have a client who wants to offer options on the first page of
I have one drop down list in my page, which contains two options. What
I have a listbox on a page: <select id=user_list name=user_list size=21 style=width:200px;> <option value=1>User

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.