Hello everyone, try to realize such a function as the drop-down list with the choice of elements as in the picture
But I can not understand what instrument it was implemented. I tried to do in the Expandable ListView but ListView requires a place on the screen, and then everything is compressed and very convenient. You can tell which way to dig or tell the ready-made solution. The spinner does not work either since when I exhibit in the layout_widh 30-60dp parameter, the application creates when you press the spinner
Answer 1
You can create your own toolbar and there as an Item place the spinner
& lt; xml version = "1.0" encoding = "UTF-8"? & gt;
& lt; Menu XMLNS: Android = "http://schemas.android.com/apk/res/android"
XMLNS: App = "http://schemas.android.com/apk/res-auto" & gt;
& lt; item
Android: id = "@ + ID / Category_spinner"
Android: title = "@ STRING / ITEM_CATEGORY"
App: ActionViewClass = "Android.widget.spinner"
App: ShowASAction = "IFROOM" / & GT;
Next Create a layout for each Sport element
& lt; xml version = "1.0" encoding = "UTF-8"? & gt;
& lt; TextView XMLNS: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "Match_Parent"
Android: layout_height = "wrap_content"
Android: Padding = "5dp"
Android: TextSize = "@ dimen / category_spinner_text_size" / & gt;
And then work with him in activati
Public Class NewSlistActivity Extends AppCompatactivity {
// Some Code.
@Override
Public Boolean OnCreateOptionsMenu (Menu Menu) {
getMenuinflater (). Inflate (R.Menu.Antivity_news_Menu_List, Menu);
CreateSpinner (Menu);
RETURN TRUE;
}
// Some Code.
Private Void CreateSpinner (Menu Menu) {
Menuitem CategorySpinner = Menu.FindItem (R.ID.category_spinner);
Spinner Spinner = (Spinner) CategorySpinner.getActionView ();
Arrayadapter & lt; String & GT; Adapter = New Arrayadapter & LT; & GT; (this,
R.Layout.categoty_spinner_item, const.category_list);
Spinner.Setadapter (Adapter);
spinner.setselection (selectedcategory);
spinner.setonitemselectedlistener (changecategorylistener);
}
}
This is an example of the Sport from my project, but I think everything is extremely clear here. If you are questions, write, supplement the answer.