0

I have a kind of form with 3 Spinners. The content of 2 Spinners (minorSpinner) depends on the selection of the first one (mainSpinner). To be more precise, I set the content of those 2 minorSpinner in the mainSpinner's onItemSelected listener.

The form can be saved and load back again.

The problem is: When I am trying to load the form, first I set the mainSpinner and then minerSpinners.

Like:

mainSpinner.setSelection(value);
minorSpinner1.setSelection(value1);
minorSpinner2.setSelection(value2);

Unfortunatelly the minorSpinners are not ready in time. Maybe because their values are set in the UI Thread?

Question:

how to wait until they are ready?

What I tried:

runOnUIThread(){
mainSpinner.setSelection(value);
minorSpinner1.setSelection(value1);
minorSpinner2.setSelection(value2);
}

but ti does not work:(

Any idea?

Remarkable
  • 549
  • 1
  • 3
  • 10

1 Answers1

0

how to wait until they are ready?

So my first idea is to register OnItemSelectedListener() for all Spinners.

Then create two boolean variables for example isSpinnerOneSelected, isSpinnerTwoSelected and when you'll select item from Spinner, assign variable to true.

Then create some Thread (with Handler) that will control your states. If both variables are assigned to true, just make action with third Spinner.

If you don't know how to use Handler, look at:

Community
  • 1
  • 1
Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106