Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.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 2.2 Froyo_Custom Titlebar - Fatal编程技术网

Android 如何自定义首选项活动的标题?

Android 如何自定义首选项活动的标题?,android,android-2.2-froyo,custom-titlebar,Android,Android 2.2 Froyo,Custom Titlebar,我有同样的问题,比如这个问题: 在扩展了首选项活动之后,我在onCreate()中编写了这段代码,它只显示了一个空白的灰色标题。我认为这是一个bug(因为这个解决方案与活动配合得很好) 已编辑: window_title.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" andro

我有同样的问题,比如这个问题:

在扩展了
首选项活动之后
,我在
onCreate()中编写了这段代码,它只显示了一个空白的灰色标题。我认为这是一个bug(因为这个解决方案与活动配合得很好)

已编辑

window_title.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:background="@color/titleBar" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" 
    android:paddingLeft="5dip" 
    android:paddingRight="5dip">

    <ImageView android:id="@+id/imageView1" 
               android:src="@drawable/megadict_icon" 
               android:layout_height="35dip" 
               android:layout_width="35dip" 
               android:layout_gravity="center_vertical" />

    <TextView android:layout_width="wrap_content" 
              android:id="@+id/textView1" 
              android:layout_height="wrap_content" 
              android:textColor="@color/white" 
              android:textSize="16dip" 
              android:layout_weight="1" 
              android:layout_gravity="center_vertical" 
              android:text="@string/appName" 
              android:paddingLeft="5dip" 
              android:paddingRight="5dip" />

    <ProgressBar style="?android:attr/progressBarStyleSmall" 
                 android:id="@+id/progressBar" 
                 android:layout_width="28dip" 
                 android:layout_height="28dip" 
                 android:layout_gravity="center_vertical" 
                 android:visibility="invisible" />

</LinearLayout>

main_pref.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:title="@string/mainPrefTitle">

    <ListPreference android:entries="@array/languageStrings" 
                    android:entryValues="@array/languageValues" 
                    android:dialogTitle="@string/languagePrefTitle" 
                    android:title="@string/mainPrefTitle" 
                    android:key="languagePrefKey" />

</PreferenceScreen>

addPreferenceFromResource()之后调用
setFeatureInt()

上述方法对我不起作用

我已经发布了答案。

检查requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)!!它返回什么?假还是真
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:title="@string/mainPrefTitle">

    <ListPreference android:entries="@array/languageStrings" 
                    android:entryValues="@array/languageValues" 
                    android:dialogTitle="@string/languagePrefTitle" 
                    android:title="@string/mainPrefTitle" 
                    android:key="languagePrefKey" />

</PreferenceScreen>