Android 如何在PreferenceActivity中显示标题

Android 如何在PreferenceActivity中显示标题,android,preferences,Android,Preferences,我使用PreferenceActivity,在本例中也使用平板电脑 但是它不会在标题中显示标题,这些广告如何扩展ListActivity?PreferenceActivity扩展ListActivity,当您使用addPreferencesFromResource()从xml扩展首选项时,它会将内容放入ListActivity使用的标准ListView中。因此,基本上,您可以使用setContentView()指定布局,但需要在其中包含一个id为“@+android:id/list”的ListV

我使用
PreferenceActivity
,在本例中也使用平板电脑


但是它不会在标题中显示标题,这些广告如何扩展ListActivity?

PreferenceActivity扩展ListActivity,当您使用addPreferencesFromResource()从xml扩展首选项时,它会将内容放入ListActivity使用的标准ListView中。因此,基本上,您可以使用setContentView()指定布局,但需要在其中包含一个id为“@+android:id/list”的ListView

在login\u settings\u layout.xml中需要一个类似以下内容的列表视图:

<ListView 
android:id="@+android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/> 

这是因为ttitle未启用

getActionBar().setDisplayShowTitleEnabled(false);
将其更改为,然后调用
setTitle()


anser的可能复制品是添加ActionBar!谢谢大家的帮助!!请发布您的答案并接受它,以便将来可以帮助其他人…addPreferencesFromResource(…)是不推荐从资源文件加载您的首选项。请参见此处的示例代码:PreferenceActivity
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
setTitle("Your Title");