Tuesday 15 June 2010

Option button not showing in action bar Android -



Option button not showing in action bar Android -

i trying add together action button , not showing in action bar, display @ button when click on hardware menu button . , button not working . sharing code , tell me wrong manifest file :

<application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" > <!-- parent activity meta-data back upwards api level 7+ --> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".secindactivity" android:label="items" android:parentactivityname=".mainactivity" > <meta-data android:name="android.support.parent_activity" android:value=".mainactivity" /> </activity> </application>

i adding button in sec activity ,. showing not working . , trying add together action bar buttons in secondactivity . menu file below :

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:digicare="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item_back" android:icon="@drawable/home2" digicare:showasaction="ifroom" android:title="home"> </item> </menu>

this java file of secondactivity :

it never comes in if statement . set log in , it never comes in if statement

@override public boolean onoptionsitemselected(menuitem item) { if ( item.getitemid() == r.id.home){ log.w("asdfasdfasdf","asdfasdf"); intent upintent = navutils.getparentactivityintent(this); navutils.navigateupto(this, upintent); } homecoming super.onoptionsitemselected(item); } @override public boolean oncreateoptionsmenu(menu menu) { menuinflater mymenu = getmenuinflater(); mymenu.inflate(r.menu.item_menu,menu); homecoming super.oncreateoptionsmenu(menu); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.items); actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true); }

these problems . how done ????

well:

first issue

this duplicate of this question. think doesn't show because have options button on device. see this post modifying behavior in reflection (however, i'm not sure recommend it, people have expectations device's behavior).

second issue

if followed code correctly, item id item_back , not r.id.home...

hth!

android android-activity android-menu

No comments:

Post a Comment