문제

I have an old app which now when run on tablets like the Xoom, hides the ActionBar. The app was written before the ActionBar existed so some old code is hiding the actionbar.

What in an old app can hide the ActionBar? I need to change it so that the ActionBar and therefore the menu can be shown:

Here's my very simple Theme:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme.Black">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowFullscreen">false</item>
    <item name="android:windowContentOverlay">@android:color/transparent</item>
</style>

  <style name="TextViewStyled" parent="@android:style/Widget.TextView">    
    <item name="android:textStyle">normal</item>         
    <item name="android:lineSpacingMultiplier">1.22</item>   
  </style>
</resources>

And here's the only window settings I use:

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_RIGHT_ICON);
도움이 되었습니까?

해결책

Using android:Theme.Black as your theme parent is what's "hiding" the action bar. The Holo and DeviceDefault theme families include an action bar by default, but the legacy theme family (from which Theme.Black derives) does not.

Use a theme declared with the same name "MyTheme" in res/values-v11/themes.xml with a parent of @android:style/Theme.Holo. This version of the theme will be used on devices running API level 11 (Android 3.0, where Holo and the action bar were introduced) or newer. You should similarly use Widget.Holo.TextView instead of Widget.TextView when declaring a custom view style to work within the Holo theme.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top