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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:42:16+00:00 2026-06-11T15:42:16+00:00

I am working on an android project and have a spinner which contains items

  • 0

I am working on an android project and have a spinner which contains items from a string-array which is in the string.xml file.

In the strings.xml I have the following array

<string-array name="array_loginType">
        <item>Select Login Type</item>
        <item>Website</item>
        <item>App</item>
        <item>Other</item>
</string-array>

and the spinner contains the following XML

<Spinner  android:id="@+id/add_cboLoginType"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:prompt="@string/add_select_login_type"
    android:padding="4dp" 
    android:entries="@array/array_loginType"/>

At some point the user can select the item from the spinner and when submitted it saves the item in the database. I am then allowing the user to edit the details and I am trying to set the selected item within the spinner based on the item that was retrieved from the database. I.e. if the saved item within the database says Website then Website will be selected inside the spinner.

Thanks for any help you can provide.

  • 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-11T15:42:17+00:00Added an answer on June 11, 2026 at 3:42 pm

    If you know what position in the array holds the correct selection, you can just use the Spinner.setSelection();-method to set the spinner to display it.

    In your example, the Website is found in position 1 of the array (1st actual entry is number 0).

    Therefore, your code should look something like this:

    // Declare the spinner object
    Spinner mySpinner = (Spinner) findViewById(R.id.add_cboLoginType);
    // Set the correct selection
    mySpinner.setSelection(1, true);
    

    The second argument tells the spinner to “animate” the selection – so it actually displays the correct selection, and not just sets the correct value (if it’s set to false or not included at all, the spinner will have changed (so anything depending on the selection will work as intended) but it’ll still appear to be at the default selection).

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

Sidebar

Related Questions

I have an Android project in eclipse IDE which was working. After some imports
I am working on an android project and I am using a spinner which
I am working on android project. I have 3 pages in which each page
I am working on android project in which I have to apply loading screen
I am currently working on android project where I want to have a text
I am currently working on an android project and I have an activity, lets
While working on an AppEngine connected Android project, I occasionally have problems with RequestFactory
I can't seem to get assertions working in my eclipse android project. I have
I am working on a android project. I n that I have to deal
In my Android project I have 3 classes: 1st a List class contains 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.