我正在使用ActionBarSherlock,并且希望实现一个类似于Google Maps中所知的主页按钮的功能。
我已经成功使用以下代码打开了一个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中检索home按钮视图?
哦,findViewById(android.R.id.home)
或findViewById(item.getItemId())
都返回null。
findViewById(R.id.abs__home);
来获取主页图标吗?我的应用程序最小SDK版本是10。 - mrsus