naresh
naresh

Reputation: 10392

android - actionbar is not visible

I want to add the action bar to the app having this theme(@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>

Upvotes: 0

Views: 780

Answers (2)

Hardik4560
Hardik4560

Reputation: 3220

Actionbar only work with .holo themes. So consider using @android:style/Theme.Holo.Light.DarkActionBar

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006539

I want to add the action bar to the app having this theme(@android:style/Theme.Black.NoTitleBar).

That, by definition, is impossible. Please switch to Theme.Black instead of Theme.Black.NoTitleBar.

Upvotes: 1

Related Questions