相关疑难解决方法(0)

ActionBarSherlock:如何访问主页按钮视图?

我正在使用ActionBarSherlock,并希望获得Google地图所知的主页按钮的类似功能.

主页按钮就像谷歌地图一样

使用以下代码按主页按钮时,我已设法打开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;
}
Run Code Online (Sandbox Code Playgroud)

但是我使用活动的简单TextView作为锚点(R.id.text).如何从ActionBar中检索主页按钮视图?

哦,findViewById(android.R.id.home)或者findViewById(item.getItemId())两者都返回null.

android actionbarsherlock android-actionbar

7
推荐指数
1
解决办法
4887
查看次数