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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:51:18+00:00 2026-05-15T16:51:18+00:00

I have a view with a spinner. The activity starts another acvitity with a

  • 0

I have a view with a spinner. The activity starts another acvitity with a popup where I add or delete values that the parent shows in the Spinner.
So, in onActivityResult() I refresh the content of the Spinner so that it reflects any additional or deleted values, by calling my fillSpinner() method.
The parameter to this method is the previously selected value:

private void fillSpinner(String value){

    Cursor c =  mDbHelper.getAllCategories();
    startManagingCursor(c);
    c.moveToFirst();

    String[] from = new String[]{DBAdapter.KEY_CATEGORY};       
    SimpleCursorAdapter scCats = new SimpleCursorAdapter(
        this, android.R.layout.simple_spinner_item,c,from,
            new int[]{android.R.id.text1});
    scCats.setDropDownViewResource(
        android.R.layout.simple_spinner_dropdown_item);
    category.setAdapter(scCats);

    if (value != null && value != "") {
        category.setSelection((int)mDbHelper.categoryIndex(value));
    }
}

When I open the Spinner, it contains the correct list (i.e. it was refreshed) and the correct value is selected. However, the Spinner control itself (in its closed state) does not show the selected value, but the first in the list.

When I step through the code in the debugger, the Spinner value is correct before and after I call setSelection() (and it is always called with the same correct id). However, since I cannot step out of the event, when I resume the execution after a short moment the value in the Spinner changes.

In other words, the spinner’s displayed string is changed and is different from the selected item when I return from my popup activity.

Any ideas are appreciated.

  • 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-15T16:51:18+00:00Added an answer on May 15, 2026 at 4:51 pm

    The problem, I think, was due to my cursor being recreated on every call. I don’t have a better explanation. This post indirectly pointed me in the right direction.

    By holding on to the cursor after creating it initially, I was able to just call requery() after changing the list data, as opposed to running through the method in my question. It works fine now.

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

Sidebar

Related Questions

I have a custom View class that extends Spinner. I'm trying to figure out
I have a spinner in my Child activity . That means my activity is
I have to develop an android view such that i have 2 spinner controls
I have an activity which shows a Spinner (selection of category of items), a
I am beginner in rails. I have view that i try to print inside
This is what I have: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import
I have an Activity with multiple Spinners in it (around 8-9). The code that
I have one spinner in which few values are there from strings.xml and I
I have a activity that extends listactivity, extended in this class i have a
I am using a spinner when selected starts an intent and the class that

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.