Kon*_*rer 7 android actionbarsherlock android-actionbar
我正在使用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.
您无法访问主视图,因为它位于内容视图上方和窗口装饰中.
Google在内容视图中存在的预蜂窝设备上使用自定义操作栏.这是允许他们进行此自定义下拉列表的原因.在Honeycomb和更新版本上,他们在系统操作栏中使用高度自定义的列表导航版本.
由于您使用的是ActionBarSherlock,因此您有两种选择:
| 归档时间: |
|
| 查看次数: |
4887 次 |
| 最近记录: |