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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:16:54+00:00 2026-06-14T22:16:54+00:00

Others has the problem as doesn’t working, I have the problem it is working

  • 0

Others has the problem as doesn’t working, I have the problem it is working ( and it shouldn’t )

I have a data model, which is saved, and need to loaded back to GUI, Activity. It has a few spinner value.

The data is place to a common accesible class, a reference holder.

The activity’s onCreate it will check if is on edit mode or not with:

editMode = getIntent().getBooleanExtra(EDIT_MODE_KEY, false);

It will load the UI elements from xml, and start selecting, filling values.
At editing mode, and at creation mode it should select values what has the data model.
At runtime ( after onResume() ) has some workflow: is something is selected at spinner1, than should refresh the spinner2 adapter content and so on.

It doesn’t worked the plain .setSelection(positiontoSelect); so I have added a delayed post, now is working.

My problem is: I would like remove for temp the selection listener, call the selection and add back the listener.

Here is the code, which should be modified:

          if (editedTimezonePosition > -1) {                        
                final int positiontoSelect = editedTimezonePosition;
                new Handler().postDelayed(new Runnable() {
                    public void run() {
                        OnItemSelectedListener listener = spSelectTimezone.getOnItemSelectedListener();
                        spSelectTimezone.setOnItemSelectedListener(null);
                        spSelectTimezone.setSelection(positiontoSelect);
                        spSelectTimezone.setOnItemSelectedListener(listener);                   
                    }
                }, 250);            
            }

setting to null the listener has no effect: I am getting callback to my listener method.

If you have any idea how to fix it, please share it!

  • 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-14T22:16:55+00:00Added an answer on June 14, 2026 at 10:16 pm

    You could put a counter variable in your onItemSelected method. If it is 0 (meaning the first time the method has been called), do nothing but increment the variable. If it is greater than 0, execute the rest of your code.

    private int mSpinnerSelectionCount=0;
    
    public void onItemSelected(AdapterView<?> parent, View view,
        int pos, long id) {
            if(mSpinnerSelectionCount == 0){
                mSpinnerSelectionCount++;
            } else {
                // Your normal selection code here
            }    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Rails app has some pages which are SSL-required and others which are SSL-optional.
I have a particular web application that like most others, has to account for
I have a table in an Oracle Database that has, among others, a DATE
I have ASP.NET MVC application that has list with jQuery Selectable list. My problem
I have problem with !IspostBack i'm working with crystal report and i use (if
I'm using javascript and jQuery. I have a problem that my web app has
I have a strange problem implementing pl/sql procedure. My procedure has four varchar input
I have an algorithmic problem in which I have derived a transfer matrix between
Imagine that I have a model that describes the printers that an office has.
Background: I have a self-taught hobbyist level of understanding of C++, which has translated

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.