0

I have one Spinner in my app. I want to show all items of spinner automatically. In this scenario, I am not even touching/Clicking on Spinner to choose item.

Is it possible to call Spinner to show its item automatically when some specific condition occur?

please, guide me how do I do this.

Pankaj Kharche
  • 1,329
  • 4
  • 15
  • 37

2 Answers2

0

You can try calling a function that contains te the code below whenever your specific condition occur. just change the contents of the array and remove the previous items and apply the new one on your spinner.

ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
SleepNot
  • 2,982
  • 10
  • 43
  • 72
  • This code is placing array to adapter and setting adapter to spinner. but my question is to give a choose option to user. @jeraldov. – Pankaj Kharche Mar 13 '13 at 07:28
  • do you know some method which call spinner to give a choice menu... or show its all items – Pankaj Kharche Mar 13 '13 at 07:32
  • What kind of option are you talking about? I answered this because you were asking if it is possible for a spinner to show its item automatically. – SleepNot Mar 13 '13 at 07:34
  • the code you have posted. it is just add items to spinner. but I have to do something like. when you click on spinner its shows you items to choose. I want the same functionality but without clicking on spinner. on different event of Option Menu in App. – Pankaj Kharche Mar 13 '13 at 07:41
  • maybe you want to set the selected item of your spinner item by using other button from another menu of some sort? if yes, then maybe this can help you http://stackoverflow.com/questions/11072576/set-selected-item-of-spinner-programmatically – SleepNot Mar 13 '13 at 11:06
0

yes you can use

  spinner.performclick();

when a paricular condition occur.

Priya
  • 1,763
  • 1
  • 12
  • 11