android - Add Spinner To Action Menu Bar -
i looking example how add spinner item array of items android menu options .
i many examples there not simple example can fine .i want add item action bar on top of screen.
spinner in right on action bar sherlock icslinearlayout
private string[] mlocations; actionbar actionbar = getsupportactionbar(); final context themedcontext = actionbar.getthemedcontext(); arrayadapter<string> adapter = new arrayadapter<string>(themedcontext, r.layout.sherlock_spinner_item, mlocations); adapter.setdropdownviewresource(r.layout.sherlock_spinner_dropdown_item); // create ics spinner spinner = new icsspinner(this, null, r.attr.actiondropdownstyle); spinner.setadapter(adapter); spinner.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(icsadapterview<?> parent, view view, int position, long id) { } @override public void onnothingselected(icsadapterview<?> parent) { } }); // configure custom view icslinearlayout listnavlayout = (icslinearlayout) getlayoutinflater() .inflate(r.layout.abs__action_bar_tab_bar_view, null); linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.match_parent); params.gravity = gravity.center; listnavlayout.addview(spinner, params); listnavlayout.setgravity(gravity.right); //align spinner right // configure action bar actionbar.setcustomview(listnavlayout, new actionbar.layoutparams( gravity.right));
Comments
Post a Comment