我的活动使用设置android:windowNoTitle = true
的主题。但我必须在某些活动中显示标题。我希望通过电话requestWindowFeature()
在我的活动中显示标题,但它不起作用!任何帮助都会很棒。
感谢。
PS: 我的活动hava要在两个主题之间切换.homeActivty使用动作栏而其他没有标题。这些活动使用相同的主题。所以在使用requestWindowFeature()之前它一直在隐藏,我只想现在展示它。
这是我的代码: 定义主题:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowAnimationStyle">@style/activityAnimation</item>
<item name="android:windowNoTitle">true</item>
<!-- <item name="android:background">@color/background_holo_light</item> -->
</style>
在申请中使用主题:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
必要时获取并更改主题:
int mThemeId = mSettingPreferences.getInt(MySettings.THEME_ID, -1);
if (-1 != mThemeId) {
this.setTheme(mThemeId);
}
// do something to show the title
答案 0 :(得分:1)
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.yourlayout);
如果您使用此功能,则无需应用任何主题。
答案 1 :(得分:0)
<activity
android:name=".HistoryImage"
android:screenOrientation="sensorPortait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".HistoryVideo"
android:screenOrientation="sensorPortait" >
</activity>
<activity
android:name=".HistoryVideo_2"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:screenOrientation="sensorPortait" >
</activity>
答案 2 :(得分:0)
you must call requestWindowFeature(); before setContentView()
答案 3 :(得分:0)
您必须在 setContentView 方法之前使用此方法...
requestWindowFeature(Window.FEATURE_NO_TITLE);
或强>
是的,您可以在Manifest文件中添加主题,其中您不想要Title的活动。然后使用它..
<activity
android:name=".activity name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:screenOrientation="potrait" >
</activity>
首先改变这个:
if (mThemeId != -1) {
this.setTheme(mThemeId);
}
然后你可以使用
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
答案 4 :(得分:0)
您不想显示标题栏的活动。这样做是为了隐藏标题栏。 befor setcontentView requestWindowFeature(Window.FEATURE_NO_TITLE);
答案 5 :(得分:0)
我希望这会对你有所帮助
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_page);