Android:标题未显示在带有自定义ListAdapter视图的自定义标题栏中
我创建了一个自定义标题栏,其中包含以下内容 myapptitle.xml 但不知何故,在运行应用程序时,我得到的标题栏中根本没有任何文本。在app_name的my strings.xml中,我将通知作为文本 感谢你所有的时间和帮助 编辑 Styles.xmlAndroid:标题未显示在带有自定义ListAdapter视图的自定义标题栏中,android,titlebar,custom-adapter,Android,Titlebar,Custom Adapter,我创建了一个自定义标题栏,其中包含以下内容 myapptitle.xml 但不知何故,在运行应用程序时,我得到的标题栏中根本没有任何文本。在app_name的my strings.xml中,我将通知作为文本 感谢你所有的时间和帮助 编辑 Styles.xml 更改style.xml,如下所示: <resources> <style name="CustomWindowTitleBarBG"> <item name="
更改style.xml,如下所示:
<resources>
<style name="CustomWindowTitleBarBG">
<item name="android:background">#323331</item>
</style>
<style name="TitleBarTheme" parent="android:Theme">
<item name="android:windowTitleSize">35dip</item>
<item name="android:windowTitleBackgroundStyle"> @style/CustomWindowTitleBarBG</item>
</style>
</resources>
android:theme="@android:style/Theme.NoTitleBar"
在活动类中使用您的代码,即:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.myapptitle);
提供完整的style.xml文件。@color/titlebackgroundcolor将您的代码放入您的问题中..不在注释中..进行了更改,但在启动活动时出现以下异常。java.lang.RuntimeException:无法启动活动组件信息{com.sas.mobi.pushclient/com.sas.mobi.pushclient.MessagesListActivity}:android.util.AndroidRuntimeException:您不能将自定义标题与其他标题功能组合在一起,以便在第一个代码部分中添加此行。错误的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/icon"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_marginLeft="4dip"
android:layout_marginRight="10dip"
android:layout_marginTop="4dip"
android:contentDescription="@string/app_msg_title"
android:src="@drawable/logo_small" >
</ImageView>
<TextView
android:id="@+id/msgDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
/>
<TextView
android:id="@+id/msgTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp" />
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="12sp" >
</TextView>
</LinearLayout>
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.myapptitle);
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
</style>
</resources>
<resources>
<style name="CustomWindowTitleBarBG">
<item name="android:background">#323331</item>
</style>
<style name="TitleBarTheme" parent="android:Theme">
<item name="android:windowTitleSize">35dip</item>
<item name="android:windowTitleBackgroundStyle"> @style/CustomWindowTitleBarBG</item>
</style>
</resources>
android:theme="@android:style/Theme.NoTitleBar"
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.myapptitle);