android - How to add a drop down menu on Actionbar without the preselected item occupying space -
i add on android actionbar drop down menu without preselected option. more precisely arrow next application's icon on actionbar. far code is:
protected void oncreate(bundle savedinstancestate) { . . . actionbar actionbar = getactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_list); spinneradapter spinneradapter = arrayadapter.createfromresource(this, r.array.logo_options, android.r.layout.simple_spinner_dropdown_item); actionbar.setlistnavigationcallbacks(spinneradapter, null); }
how can rid of text on actionbar?
you can create popup menu drops down whenever click on action bar button:
view menuitemview = findviewbyid(r.id.apps); popupmenu popupmenu = new popupmenu(this, menuitemview); popupmenu.getmenuinflater().inflate(r.menu.popup, popupmenu.getmenu()); popupmenu.setonmenuitemclicklistener(new onmenuitemclicklistener() { @override public boolean onmenuitemclick(menuitem item) { if (item.getitemid() == r.id.windowitem1) //do whatever want if (item.getitemid() == r.id.windowitem2) //do whatever want if (item.getitemid() == r.id.windowitem3) //do whatever want return false; } }); popupmenu.show();
actionbar text can removed android:showasaction="" property,you can set accordingly.....
Comments
Post a Comment