操作栏没有显示:Theme.Appcompat.Light.DarkActionBar在preference活动 [英] Action bar not showing :Theme.Appcompat.Light.DarkActionBar in preference activity

查看:235
本文介绍了操作栏没有显示:Theme.Appcompat.Light.DarkActionBar在preference活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的preference活动使用,因为漂亮的复选框的这个主题,但我的操作栏没有显示。

I want to use this theme in my preference activity because of the nice checkbox but my action bar isn't showing.

推荐答案

preferenceActivity 不延伸 ActionBarActivity ,这是需要采取行动酒吧是可用的。

PreferenceActivity does not extend ActionBarActivity, which is required for action bar to be available.

如果你需要一个preferences屏幕与操作栏,尝试使用 preferenceFragment 内的 ActionBarActivity 代替。

If you need a preferences screen with action bar, try to use PreferenceFragment inside an ActionBarActivity instead.

public class SettingsActivity extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new SettingsFragment())
                .commit();
    }
}

public static class SettingsFragment extends PreferenceFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.preferences);
    }
    ...
}

参考: http://developer.android.com/guide/专题/ UI / settings.html#片段

这篇关于操作栏没有显示:Theme.Appcompat.Light.DarkActionBar在preference活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆