【发布时间】:2012-04-17 08:13:40
【问题描述】:
我正在使用 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;
}
但是,我使用活动的简单 TextView 作为锚点 (R.id.text)。如何从那里的 ActionBar 中检索主页按钮视图?
哦,findViewById(android.R.id.home) 或 findViewById(item.getItemId()) 都返回 null。
【问题讨论】:
标签: android android-actionbar actionbarsherlock