3

I am facing a problem about spinner. Suppose an spinner dialog is pop up and if in that time locking of screed occur when I unlock the screen the spinner pop up is not shown there. Can anyone suggest me any solution of this or can anyone know how to pragmatically pop up spinner dialog in onResume.

kaiz.net
  • 1,984
  • 3
  • 23
  • 31
Farhana Haque
  • 1,371
  • 14
  • 23

2 Answers2

18

Try spinner.performClick();. For me it is working.

Blehi
  • 1,990
  • 1
  • 18
  • 20
  • Please also check this thread: http://stackoverflow.com/questions/5555549/android-spinner-performclick-onitemselected – Blehi Apr 06 '12 at 09:12
  • And this: http://stackoverflow.com/questions/2679804/possible-to-programmatically-open-a-spinner-in-android-app – Blehi Apr 06 '12 at 09:13
  • The difference between when it works and when it doesn't is the UI thread. You can only call that method from the UI thread so the onResume would need to set a runonUI in order to invoke. – Tatarize Mar 06 '15 at 18:11
  • When using a dialog my spinner gets open behind the dialog using performClick(); Any solution for this? – Huzaifa Asif Dec 21 '20 at 07:20
0

Try This

Spinner spinner = new Spinner(this);
    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray); //selected item will look like a spinner set from XML
    spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(spinnerArrayAdapter);
Pratik Vyas
  • 644
  • 7
  • 20