Reputation: 6140
I have a Spinner:
Spinner country_list=new Spinner(this);
ArrayAdapter<String> adapter= new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countries);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
country_list.setAdapter(adapter);
Now I want to show it as popup for user to select. Do I need to use AlertDialog or is there even a simpler way?
/EDIT: Actually, what I want is not Spinner. I want to get a list of countries when user clicks a button and then he or she can select a country. So basically his is the "second part" of Spinner - where a list shows in a popup. Should I use ListView?
Upvotes: 0
Views: 1233
Reputation: 6140
What I needed was
country_list.performClick()
to display spinner with a button click.
Upvotes: 3
Reputation: 7634
If you want the spinner itself to be in a pop up, you have to use a dialog.
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.addContentView(country_list, params);
d.show();
Upvotes: 1
Reputation: 40406
Now I want to show it as popup for user to select. Do I need to use AlertDialog or is there even a simpler way?
-spinner already show as a pop-up and you can get selected value no need use alertDialog.
Upvotes: 1