android - how I can access menu items in fragment? -
i created menu items in main activity have fragment , wanna access menu items ( copy , paste,share ) in fragment .
public class frag_angel extends fragment { ..... @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { wrapper = new linearlayout(getactivity()); setretaininstance(true); v = inflater.inflate(r.layout.frag_angel, wrapper, true); sethasoptionsmenu(true); ..... }
i wrote below code does't work me !
public boolean onoptionsitemselected(android.view.menuitem item) { switch (item.getitemid()) { case r.id.copy:{ refreshlist(); // add measurement } default: return super.onoptionsitemselected(item); } } private void refreshlist() { // todo toast.maketext(getactivity(), "refreshing first list...", toast.length_short).show(); }
and can't use getsystemservice !
you need override onoptionsitemselected.
Comments
Post a Comment