アプリケーションをテストしている 2 つのデバイス、Galaxy Nexus と Desire HD (ハードウェア ボタン付き) があります。
このようなメニューを実装しています
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.feedback:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"test@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, " feedback");
i.putExtra(Intent.EXTRA_TEXT , "");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
return true;
case R.id.about:
Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
return true;
default:
return true;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
Galaxy nexus では、アクション バーのメニュー ボタンが表示され、メニューが膨らみ、すべて正常に動作します。アクション バーの Desire HD では、ハードウェア ボタンがあるためメニュー ボタンが表示されませんが、ハードウェア メニュー ボタンを押しても何も起こりません。
どうすればこれを修正できますか?
編集:これは私のxmlです
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/feedback"
android:icon="@drawable/ic_launcher"
android:title="Feedback"
android:showAsAction="never"/>
<item android:id="@+id/about"
android:icon="@drawable/ic_launcher"
android:title="About" />
</menu>