Last active
April 12, 2023 12:54
-
-
Save marczych/6908324 to your computer and use it in GitHub Desktop.
This is a workaround for `android:showAsAction="withText"` not displaying text on narrow layouts e.g. in portrait on phones. This uses styles found in ActionBarSherlock so it matches the native styling. I tested it with ABS v4.4.0 but earlier versions are probably compatible.Note: This should only be used if you absolutely have to display the te…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends Activity { | |
... | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Trigger onOptionsItemSelected for the custom menu item because it doesn't | |
// happen automatically. | |
final MenuItem item = menu.findItem(R.id.button_id); | |
barcodeItem.getActionView().setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
onOptionsItemSelected(item); | |
} | |
}); | |
// This sets up the long press listener to make the tool tip. | |
// CheatSheet can be found here: https://gist.github.com/romannurik/3982005 | |
CheatSheet.setup(item.getActionView(), R.string.text); | |
return super.onCreateOptionsMenu(menu); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment