Evan Bashir
Evan Bashir

Reputation: 5551

Creating Options / Spinner Menus

I'm trying to create a dropdown menu that doesn't swap text like a traditional spinner. Ideally, I'd like to have an icon that triggers the dropdown seen below when tapped.

Is there a better way to create dropdowns like this?

EDIT: Android Popup Menu is the way to go!

The example below was created with a dropdown spinner.

What I Have:

dropdownexample

What I Want:

dropdownexample2

Spinner Code:

Spinner spinner = (Spinner) view.findViewById(R.id.addCustomer);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
getActivity(), R.array.add_customer, R.layout.spinner_item_icon);
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item_icon);
spinner.setAdapter(adapter);

Upvotes: 0

Views: 105

Answers (1)

prijupaul
prijupaul

Reputation: 2086

How about having a PopupWindow. When you click the icon, you can show a PopupWindow with ListView. You can find sample code here

Upvotes: 1

Related Questions