3

PreferenceActivity在这个例子中使用以及从 4.0 开始的平板电脑 Android

但是标题中不显示标题,怎么会有这些广告呢?

4

2 回答 2

1

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

protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.login_settings);
setContentView(R.layout.login_settings_layout);}

您将需要 login_settings_layout.xml 中的 ListView,如下所示:

<ListView 
android:id="@+android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/> 
于 2012-11-06T07:12:11.040 回答
0

This is beacause ttitle is not enabled.

getActionBar().setDisplayShowTitleEnabled(false);

Change it to and then call setTitle()

getActionBar().setDisplayShowTitleEnabled(true);
setTitle("Your Title");
于 2014-11-19T11:51:57.247 回答