Skip to content

Instantly share code, notes, and snippets.

@khris
Last active August 29, 2015 13:57
Show Gist options
  • Save khris/9801921 to your computer and use it in GitHub Desktop.
Save khris/9801921 to your computer and use it in GitHub Desktop.
Hack ActionBar
View decorView = getWindow().getDecorView();
int actionBarViewId = decorView.getContext().getResources().getIdentifier("android:id/action_bar", null, null);
View actionBarView = getWindow().getDecorView().findViewById(actionBarViewId);
actionBarView.setClickable(true);
actionBarView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(v.getContext(), "ActionBar is clicked", Toast.LENGTH_LONG).show();
}
});
@khris
Copy link
Author

khris commented Mar 27, 2014

It's only tested on Android SDK, not AppCompat and other libs that mimics ActionBar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment