I am using ActionBarSherlock and want a similiar functionality of the home button as it is known by Google Maps.
I already managed to open a QuickAction (http://code.google.com/p/simple-quickactions/) when pressing the home button with this piece of code:
@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;
}
However I am using a simple TextView of the activity as an anchor (R.id.text). How do I retrieve the home button view from the ActionBar there?
Oh, and findViewById(android.R.id.home)
or findViewById(item.getItemId())
both return null.
You cannot access the home view because it exists above the content view and in the window decoration.
Google uses a custom action bar on pre-Honeycomb devices which exists inside the content view. This is what allows them to make this custom dropdown. On Honeycomb and newer they use a highly customized version of list navigation in the system action bar.
Since you are using ActionBarSherlock you have two options: