java - update onOptionsItemSelected() without setting a new a listener -
so have couple of settings fragments, , want diffrent things when 'save' icon pressed, can toolbar.setonmenuitemclicklistener
, imply setting listener every other fragment, , doesn't feel right, what's right way this?
if understand question correctly, try following:
in fragments, override method onoptionsitemselected()
. if you've correctly assigned options menu save button item id, may write following code achieve want.
@override public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); switch (id) { case r.id.save_button: // sure replace id yours! // <this should put code button's action> return true; } return super.onoptionsitemselected(item); }
Comments
Post a Comment