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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:15:44+00:00 2026-05-30T18:15:44+00:00

I have a spinner with a custom adapter displaying objects from a database. When

  • 0

I have a spinner with a custom adapter displaying objects from a database.
When the object list changed I create a new adapter with the List and apply it on the spinner. Afterwards the first item is selected, so I tried this:

// 5th item selected
int pos = spinner.getSelectedItemPosition();
spinner.setAdapter(newAdapter);
// 0th item selected
spinner.setSelectedItem(pos);
// 5th item is selected

But the GUI does still show the first item?

spinner.invalidate() did not help.

Is this the correct way to achieve what I want? I really could not find any information on this behavior.

  • 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-30T18:15:46+00:00Added an answer on May 30, 2026 at 6:15 pm

    Solved: I guess the main problem was the custom spinner adapter. This works fine now

    if (spinner.getCount() > 0) {
        pos = spinner.getSelectedItemPosition();
    }
    MySpinnerAdapter adapter = new MySpinnerAdapter(context, myNewObjects);
    spinner.setAdapter(adapter);
    spinner.setSelection(pos); // needed
    adapter.notifyDataSetChanged();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spinner getting views from a custom base adapter. The problem is
I have 2 spinner, each spinner's data loaded from database using AsyncTask i call
I've created a custom adapter for my spinner because I wanted to have multiple
I have a custom spinner (customized for formatting). It works fine and shows the
I have a AS spinner class that I downloaded from Jake Hawkes ( click
I have a custom spinner that uses two custom views, one for the drop
I have a spinner set up like this: ArrayAdapter<String> states = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
I have a Spinner Control bind with data from Sqllite during the Page Load
I have my spinner pulling from an array,(that works).. What I want to happen
I have a listview which loads its data from sqlite database. Each row in

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.