ActionBarSherlock:如何访问主页按钮看法? [英] ActionBarSherlock: how to access home button view?
问题描述
我使用ActionBarSherlock并希望home键,因为它是由谷歌地图知的一个类似的功能。
I am using ActionBarSherlock and want a similiar functionality of the home button as it is known by Google Maps.
我已经成功地打开一个QuickAction上(http://$c$c.google.com/p/simple-quickactions/)时pressing home键与这片code:
I already managed to open a QuickAction (http://code.google.com/p/simple-quickactions/) when pressing the home button with this piece of code:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
View anchor = findViewById(R.id.text); // how do I get the home button view here?
quickAction.show(anchor);
return true;
}
return false;
}
不过,我现在用的是活动的一个简单的TextView作为一个锚(R.id.text)。如何重新获取从动作条有home键有何看法?
However I am using a simple TextView of the activity as an anchor (R.id.text). How do I retrieve the home button view from the ActionBar there?
哦, findViewById(android.R.id.home)
或 findViewById(item.getItemId())
都返回空值。
推荐答案
您也不能因为存在上述内容视图和窗饰访问主视图。
You cannot access the home view because it exists above the content view and in the window decoration.
谷歌使用的pre-蜂窝设备的自定义操作栏上所存在的内容视图中。这是什么让他们做出这个自定义下拉。在蜂窝和更新他们使用系统中的操作栏的列表导航高度定制的版本。
Google uses a custom action bar on pre-Honeycomb devices which exists inside the content view. This is what allows them to make this custom dropdown. On Honeycomb and newer they use a highly customized version of list navigation in the system action bar.
由于您使用的ActionBarSherlock你有两个选择:
Since you are using ActionBarSherlock you have two options:
- 转到了新样式的导航和自定义内置列表导航。
- 供应它模仿主视图自定义导航视图(如,有你的应用程序图标的话)。有了这个自定义视图,你将能够提供在其上的自定义弹出菜单可以附加一个锚。
这篇关于ActionBarSherlock:如何访问主页按钮看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!