[英]ActionBarSherlock: how to access home button view?
我正在使用ActionBarSherlock,并希望有类似Google地图已知的Home按钮的功能。
在按下带有以下代码的主页按钮时,我已经设法打开QuickAction( http://code.google.com/p/simple-quickactions/ ):
@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)。 如何从那里的ActionBar检索主页按钮视图?
哦,并且findViewById(android.R.id.home)
或findViewById(item.getItemId())
都返回null。
您无法访问主视图,因为它位于内容视图上方和窗口装饰中。
Google在内容视图内的蜂窝前设备上使用了自定义操作栏。 这就是允许他们进行此自定义下拉菜单的原因。 在Honeycomb及更高版本上,他们在系统操作栏中使用高度自定义的列表导航版本。
由于使用的是ActionBarSherlock,因此有两个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.