setHomeButtonEnabled在preferenceActivity和嵌套preference嵌套、setHomeButtonEnabled、preferenceActivity、prefe

2023-09-12 02:41:39 作者:后来呢

我有延长preference屏幕 preferenceActivity 。对于面向OS 4.0.3,我想补充< 的操作栏中的图标,所以我在的onCreate这样做()

I have preference screen extended PreferenceActivity. For targeting OS 4.0.3, I wanted to add < icon on action bar so I did this in onCreate().

ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);

它的工作。 &LT; 添加到应用程序图标的左下角。但是,当我点击它进入一个新的水平(更详细的屏幕)的项目中,&LT; 将不显示。回到顶端水平,&LT; 再次出现

It worked. < was added to left of app icon. But when I tap the item which goes into the next level (more detail screen), the < won't be displayed. Returning to the top level, the < appears again.

我从来没有想过的嵌套preference一个机制,因为聪明的 preferenceActivity 隐藏它。现在的问题是,为什么不会 preferenceActivity 显示&LT; 嵌套preference?

I have never thought about a mechanism of nested preference since smart the PreferenceActivity hides it. Now my question is, why won't PreferenceActivity display the < on nested preference?

我不想争辩,我不需要&LT增加; 至preference屏幕。 (甚至一些谷歌的应用程序添加,有的没有,所以我觉得有这个没有坚实的规则。)

I don't want to argue that I don't need to add < to the preference screen. (Even some of Google's app add, some don't, so I think there is no solid rule for this.)

如果有这个一个简单的解决方案,我想解决这个问题。

If there is a simple solution for this, I want to solve this issue.

推荐答案

而不是动态添加,你应该通过编写自定义动作条的风格要与您的应用程序的主题使用添加箭头。 (基本上,请参阅http://stackoverflow.com/a/16247111/582004)

Instead of dynamically adding this, you should add the arrow by writing a custom ActionBar style to be used with your application theme. (Basically, see http://stackoverflow.com/a/16247111/582004)