本文介绍了Android的活动通话requestWindowFeature第一和显示标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我Activitys使用哪些设置主题的android:windowNoTitle = TRUE 。但我必须展示一些活动的称号。我想通过电话 requestWindowFeature(),但它不工作显示标题在我的活动!任何帮助将是巨大的。

感谢。

PS:
2 themes.The homeActivty之间进行切换我activitys HAVA使用动作条和其他人没有title.These activtys在使用前requestWindowFeature时所使用的相同的themes.So()它一直躲在,我只是想现在表现出来。

下面是我的codeS:
定义主题:

 <! - 应用的主题。 - >
<样式名称=AppTheme父=AppBaseTheme>    <! - 所有自定义不特定于一个特定的API级别的可以去这里。 - >
    <项目名称=机器人:windowAnimationStyle> @风格/ activityAnimation< /项目>
    <项目名称=机器人:windowNoTitle>真< /项目>
    !< - <项目名称=机器人:背景> @彩色/ background_holo_light< /项目> - >
< /风格>

和在应用程序中使用的主题是:

 <应用
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>

获取并在必要时更换主题:

  INT mThemeId = mSetting preferences.getInt(MySettings.THEME_ID,-1);
    如果(-1!= mThemeId){
        this.setTheme(mThemeId);
    }
    //做一些事情来显示标题


解决方案

您之前使用这种方法,您的的setContentView 方式...

  requestWindowFeature(Window.FEATURE_NO_TITLE);

是的,你可以添加清单文件的主题在其中的活动,你不想Title..Then使用。

 <活动
        机器人:名字=活动名称
         机器人:主题=@安卓风格/ Theme.Black.NoTitleBar
        机器人:screenOrientation =potrait>
    < /活性GT;

第一个变化是:

 如果(mThemeId!= -1){
    this.setTheme(mThemeId);
}

和之后,你可以使用

  requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

My Activitys use a theme which set android:windowNoTitle = true.But I have to show the title in some activities. I want show the title in my activity by call requestWindowFeature(), but it's not work! Any help would be great.

Thanks.

ps:My activitys hava to be switched between two themes.The homeActivty use the actionbar and others no title.These activtys are use the same themes.So when before use requestWindowFeature() it's been hiding, and i just want show it now.

Here is my codes:Defined theme:

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

And use the theme in application:

    <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

Get and change the theme if necessary:

int mThemeId = mSettingPreferences.getInt(MySettings.THEME_ID, -1);
    if (-1 != mThemeId) {
        this.setTheme(mThemeId);
    }
    // do something to show the title
解决方案

you have to use this method before your setContentView method...

requestWindowFeature(Window.FEATURE_NO_TITLE);

OR

And yes you can add theme in Manifest file in which Activity you don't want to Title..Then use this..

    <activity
        android:name=".activity name"
         android:theme="@android:style/Theme.Black.NoTitleBar" 
        android:screenOrientation="potrait" >
    </activity>

first change this:

if (mThemeId != -1) {
    this.setTheme(mThemeId);
}

and after that you can use

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

这篇关于Android的活动通话requestWindowFeature第一和显示标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 02:33