简体   繁体   English

android-操作栏不可见

[英]android - actionbar is not visible

I want to add the action bar to the app having this theme(@android:style/Theme.Black.NoTitleBar). 我想将动作栏添加到具有此主题的应用程序中(@android:style / Theme.Black.NoTitleBar)。 These menu items are visible in the mobiles if you press and hold the recent apps button but in case of tablets it's not working.I tried but i am not getting. 如果您按住最近的应用程序按钮,这些菜单项将在手机中可见,但如果使用平板电脑则无法正常工作。 please can anyone help me. 请任何人能帮助我。

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;
  }
 ................
 .................
}

Manifest 表现

< ?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>

Menu 菜单

    < ?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>

I want to add the action bar to the app having this theme(@android:style/Theme.Black.NoTitleBar). 我想将动作栏添加到具有此主题的应用程序中(@android:style / Theme.Black.NoTitleBar)。

That, by definition, is impossible. 根据定义,这是不可能的。 Please switch to Theme.Black instead of Theme.Black.NoTitleBar . 请切换到Theme.Black而不是Theme.Black.NoTitleBar

Actionbar only work with .holo themes. 动作栏仅适用于.holo主题。 So consider using @android:style/Theme.Holo.Light.DarkActionBar 因此,请考虑使用@android:style / Theme.Holo.Light.DarkActionBar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM