添加按钮来preferenceScreen [英] Add up button to PreferenceScreen

查看:271
本文介绍了添加按钮来preferenceScreen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不通我怎么会去的 preferenceScreen 实施上按钮。上按钮显示插入符号在你的动作条旁边的应用程序图标,可以让你浏览应用程序的层次,更多信息的这里

I can't figure out how I would go about implementing an up button in a PreferenceScreen. An up button displays a caret in your action bar next to your app icon that allows you to navigate the app's hierarchy, more info here.

我有一个preference片段,我的主要活动被打开,我可以得到向上按钮显示,加入这一行的时候会显示getActionBar()setDisplayHomeAsUpEnabled(真)。

I have a Preference Fragment that displays when my main activity is opened and I can get the up button to display by adding this line " getActionBar().setDisplayHomeAsUpEnabled(true);":

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getFragmentManager().beginTransaction()
    .replace(android.R.id.content, new SettingsFragment())
    .commit();

这导致了按钮在preference片段显示,但我只是想展现了按钮,当我的 preferenceScreens 打开之一,让导航主 preferenceFragment

This causes the up button to display in the Preference Fragment, but I only want to show the up button when one of my PreferenceScreens is opened, allowing navigation to the main PreferenceFragment.

我的应用程序是类似的主要设置应用程序。只有子屏幕,像位置访问,从主设置应用程序中打开了向上的箭头。

My app is analogous to the main settings app. Only the child screens, like Location Access, that opens from the main Settings app has the up arrow.

推荐答案

如果您的完整的应用程序是preferences屏幕,那么你可以让你的主要活性 preferenceActivity 和子水平可以片段。这样,向上的功能将是在默认情况下,你所期待的。

If your complete application is a preferences screen, then you can make your main activity a PreferenceActivity and the sub-levels can be fragments. This way the 'up' functionality is going to be by default what you are looking for.

这篇关于添加按钮来preferenceScreen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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