私の Sherlock アクション バーは、samsung galaxy s2 4.0.3 とエミュレーター 2.1 では動作しますが、nexus 10 4.2.2 では動作しません。理由がわかりません。
ここに私の関連コードがあります:
主な活動:
ActionBar ab = getSupportActionBar();
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowHomeEnabled(false);
...
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId()) {
// do stuff with CalendarContract
case R.id.action_settings:
Intent viewIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(viewIntent, 2);
break;
case R.id.add_alarm:
loadTimer();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
return true;
}
マニフェスト :
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/icon_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AlarmReceiverActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".SettingsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".PickADayActivity"
android:excludeFromRecents="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Dialog" >
</activity>
<receiver android:name="com.paradroid.paradroidalarm.MyBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.appflood.AFPanelActivity"
android:configChanges="keyboardHidden" >
</activity>
<activity
android:name="com.appflood.AFFullScreenActivity"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent" >
</activity>
<activity android:name="com.appflood.notification.NotificationActivity" >
<intent-filter>
<action android:name="" />
</intent-filter>
</activity>
<activity
android:name="com.appflood.AFListActivity"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent" >
<intent-filter>
<action android:name="" />
</intent-filter>
</activity>
<activity
android:name="com.appflood.AFInterstitialActivity"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent" >
</activity>
<!-- gcm service and receiver -->
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
style.xml :
<?xml version="1.0" encoding="utf-8"?>
-->
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="dialog_theme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="MyTheme" parent="@style/Theme.Sherlock.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionMenuTextColor">#FFFFFF</item>
</style>
<style name="MyActionBar" parent="@style/Theme.Sherlock.Light.DarkActionBar">
<item name="android:background">#89C2F6</item>
</style>
メインメニュー.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/add_alarm"
android:icon="@drawable/add_alarm"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/add_alarm_title"/>
<item
android:id="@+id/action_settings"
android:showAsAction="ifRoom"
android:title="@string/menu" >
</item>
ありがとう。