このテーマ(@android:style/Theme.Black.NoTitleBar)を持つアプリにアクションバーを追加したいです。最近のアプリ ボタンを長押しすると、これらのメニュー項目がモバイルに表示されますが、タブレットの場合は機能しません。誰でも私を助けてください。
code
/**
* The purpose of this Activity is to manage the activities in a tab.
* Note: Child Activities can handle Key Presses before they are seen here.
* @author Eric Harlow
*/
public class TabGroupActivity extends ActivityGroup {
..................
..............
public boolean onCreateOptionsMenu(Menu menu){
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.app_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.AppExit:
showDialog(DIALOG_exitbtnalert);
break;
case R.id.AppLogout:
showDialog(DIALOG_logoutbtnalert);
break;
}
return super.onOptionsItemSelected(item);
}
//Alert dialog for Exit and Logout
protected Dialog onCreateDialog(int id)
{
switch (id)
{
case DIALOG_exitbtnalert:
return new AlertDialog.Builder(getParent())
.setTitle("MyMedPix247 Alert")
.setMessage("Are you sure you want to Exit from the App?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
DH_Constant.blnAppExit = true;
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
dialog.dismiss();
}
})
.create();
case DIALOG_logoutbtnalert:
return new AlertDialog.Builder(getParent())
.setTitle("MyMedPix247 Alert")
.setMessage("Are you sure you want to Logout?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
DH_Constant.blnApplogout = true;
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
dialog.dismiss();
}
})
.create();
}
return null;
}
................
.................
}
マニフェスト
< ?xml version="1.0" encoding="utf-8"?>
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibkr.dicomhub"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="11"/>
<application
android:icon="@drawable/dhapp_icon"
android:label="@string/app_name"
android:debuggable="true"
android:name="MyApplication"
android:theme="@android:style/Theme.Black.NoTitleBar">
<activity android:name=".DH_Home" android:windowSoftInputMode="stateHidden"
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>
</application>
< /manifest>
メニュー
< ?xml version="1.0" encoding="utf-8"?>
< menu xmlns:android="http://schemas.android.com/apk/res/android">
< item android:id="@+id/AppExit"
android:title="Exit"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/exit_icon" />
< item android:id="@+id/AppLogout"
android:title="Logout"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/logout_icon" />
< /menu>