Work with android action bar items with layout and without java class -
i'm trying open dialog (layout-xml)(without java class !!) 1 action bar called about.so, onoptionsitemselected codes :
public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); switch (item.getitemid()) { case r.id.action_settings: toast.maketext(this, "settings selected", toast.length_short).show(); return true; case r.id.action_about: locationfound(); return true; default: return super.onoptionsitemselected(item); } } private void locationfound() { intent = new intent(mainactivity.this, aboutdialog); startactivity(i); } then when want add dialog (layout) file in :
intent = new intent(mainactivity.this, aboutdialog); not allowed this.also, tried before intent :
startactivity(new intent(mainactivity.this, aboutdialog)); the problem app cannot find/accept aboutdialog.
so question is,
how can this, when clicked about button in action bar, show aboutdialog ?
thanks in advance.
you don't need intent display dialog. change locationfound() method this
private void locationfound(view view) { dialog dialog = new dialog(youractivityname.this); dialog.setcontentview(r.layout.dialog_layout); dialog.show(); }
Comments
Post a Comment