android - ActionBar app icon as home -
i want app icon in top left return when pressed, i'm using
setdisplayhomeasupenabled(true);
and arrow icon appears, pressing doesn't anything, why? here's oncreate:
@override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); android.app.actionbar ab = getactionbar(); ab.settitle("aritmetik"); ab.setdisplayhomeasupenabled(true); setlistadapter(new arrayadapter<string>(aritmetik.this, android.r.layout.simple_list_item_1, classes)); }
you have override onoptionsitemselected()
.
@override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: // app icon in action bar clicked; go home intent intent = new intent(this, homeactivity.class); intent.addflags(intent.flag_activity_clear_top); startactivity(intent); return true; default: return super.onoptionsitemselected(item); } }
(from http://developer.android.com/guide/topics/ui/actionbar.html#home)
Comments
Post a Comment