[英]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.