Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何为应用程序设置标签,但为所有活动设置为空?_Android_Android Activity_Label - Fatal编程技术网

Android 如何为应用程序设置标签,但为所有活动设置为空?

Android 如何为应用程序设置标签,但为所有活动设置为空?,android,android-activity,label,Android,Android Activity,Label,简短的问题: 我使用actionBarSherlock库,只希望将应用程序的标签设置为某个字符串,但除非另有规定,否则所有活动都有空标签 我知道您可以检查每个活动并将其标签设置为“”,但有更好的解决方案吗?喜欢使用这些样式吗?我试着把: <item name="android:label"></item> 在那里,但它什么也没做 编辑:事实是,出于某种原因,将所有活动的标签设置为“”,实际上还更改了某些android版本(在galaxy s mini上测试,and

简短的问题:

我使用actionBarSherlock库,只希望将应用程序的标签设置为某个字符串,但除非另有规定,否则所有活动都有空标签

我知道您可以检查每个活动并将其标签设置为“”,但有更好的解决方案吗?喜欢使用这些样式吗?我试着把:

<item name="android:label"></item>

在那里,但它什么也没做


编辑:事实是,出于某种原因,将所有活动的标签设置为“”,实际上还更改了某些android版本(在galaxy s mini上测试,android 2.3)上应用程序的标签,因此其名称也是“”。怎么会?是虫子吗


这是android或我测试过的任何启动器上的一个bug


似乎将活动的标签设置为“”(或至少是主标签)会将应用程序的名称设置为“”,因此应用程序标签的标签仅用于其所有活动的默认值。

您可以通过在应用程序主题中添加
true
来删除整个标题栏。我不认为你应该有一个没有标题的标题栏(除非在运行3.0或更高版本的设备上,标题栏变成了ActionBar并具有更多功能),因为它只会浪费宝贵的空间

如果您是在3.0+和2.3上开发,请在主题中添加以下元素:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="@android:style/Widget.ActionBar">
    <item name="android:displayOptions">showHome|useLogo</item>
</style>
AndroidManifest.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppBaseTheme" parent="android:Theme.Holo">
        <!-- Base Theme style elements -->
    </style>

    <style name="AppTheme" parent="AppBaseTheme">
        <!-- Other style elements. -->
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>

    <style name="AppThemeWithTitle" parent="AppTheme">
        <item name="android:actionBarStyle">@style/ActionBarWithTitle</item>
    </style>

    <style name="ActionBar" parent="@android:style/Widget.ActionBar">
        <!-- Other ActionBar style elements. -->
        <item name="android:displayOptions">showHome|useLogo</item>
    </style>

    <style name="ActionBarWithTitle" parent="ActionBar">
        <item name="android:displayOptions">showHome|useLogo|showTitle</item>
    </style>

</resources>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.themes"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.themes.Activity1"
            android:theme="@style/AppThemeWithTitle">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.example.themes.Activity2" />
        <activity
            android:name="com.example.themes.Activity3" />

    </application>

</manifest>


Activity1将显示标题,但Activity2和Activity3将不显示标题。

这不是我要求的。我在动作栏上放了一些东西,比如图标和一些动作项目。有时我需要放置文本,有时我不创建另一个主题,例如
TitleTheme
,它继承自
AppTheme
,但使用
showtheme
。然后将其设置为清单中相关活动的主题。这样,活动将没有标题作为默认。我不明白。请按代码显示(包括舱单)好吗?可能是一个示例?@androiddeveloper,我在编辑中添加了一个
style.xml
AndroidManifest.xml
的示例。这应该可以工作,但它有一些缺陷:在运行时设置标题需要重新启用标题,对于我已经拥有的每个主题,我需要创建两个“扩展”它的主题。还有其他可能的解决办法吗?