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 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 view that I want to add some custom drawing to. I
I have a view that has a list of jobs in it, with data
I have a view using a master page that contains some javascript that needs
I have a view user control that can post form. This control can be
We have a View (call it X) that is the base view called by
I have a View that can vary significantly, depending on the 'mode' a particular
I have a View class (OrderView.aspx) which shows the details of an order (Account
I have a view that is joining two tables and ordering by the first
I am trying to add an animated spinner inside a EditText view to the
I have a view which contains a form, the form posts and the data

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.