java - How I call my ownMethod in Popup Menu -
Do I want to show the list view in the popup menu? I initializeVars () method icall I program method how I showPopupMenu (View v) to the List View
public void initializeVars () {lv_sample = (ListView) to tell solutions findViewById (R Creation id.lv_sample); Adapters = new arreptopter & lt; String & gt; (This, R. Late .Stotal, RID, tv_content, value); If return (adapter == blank); Lv_sample.setAdapter (adapter); } Private Zero Show popup menu (see V) {popup menu popup menu = new popup menu (main activity. This, V); PopupMenu.getMenuInflater (). Flood (R.Man.Man, popup menu.gate menu ()); Show PopupMenuksetOnMenuItemClickListener (new Popapmenu. OnMenuItemClickListener () {Menuaitmklik (Menuitm before public boolean) {toast. Make text (main activity. This, Aitmktstring (), toast. Elananacti_eloji). (); Return true;}} ); PopupMenu.show (); After
& lt; Menu xmlns: Android = "http: // schema. Android.com/apk/res/android" & gt; & Lt; Item android: id = "@ + id / pop1" Android: orderInCategory = "100" Android: showAsAction = "never" android: title = "@ string / hello_world" / & gt; & Lt; Item android: id = "@ + id / pop2" Android: orderInCategory = "100" Android: showAsAction = "never" android: title = "@ string / hello_world" / & gt; & Lt; Item android: id = "@ + id / pop3" Android: orderInCategory = "100" Android: showAsAction = "never" android: title = "@ string / hello_world" / & gt;
Increasing it with the popup menu will show items as a list by default ....
But if you still have a Companies want to show you:
you can expand DialogFragment ...
public class DefaultViewDialog extends DialogFragment {@Override public discourse onCreateDialog (bundled savedInstanceState) {// TODO Automatic Created Stub AlertDialog.Builder dialogBuilder = New AlertDialog.Builder (getActivity ()); // The following code comments dialog box check box produces list // DIOL Oghblider Settlement ChoiceITIT (RR. Default view_are, empty, empty); / * SetItems (id) creates a simple list * / dialogBuider.setItems (R.array.DefaultView_array, null, null); Return dialog Bilder.create (); } }
Hopefully I have helped
Comments
Post a Comment