Programmatically Display Actionbar Overflow July 02, 2024 Post a Comment I have an actionbar with a menu. When you click the button, the menu shows up and all is well with the world. this answer here's how you can do it:View mOverflow; @OverrideprotectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final View decor = getWindow().getDecorView(); decor.post(newRunnable() { @Overridepublicvoidrun() { ArrayList<View> results = newArrayList<>(); decor.findViewsWithText(results, "OVERFLOW", View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); if (results.size() == 1) { mOverflow = results.get(0); } } }); } @OverridepublicbooleanonCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); returntrue; } privatevoidshowMenu() { actionbar.show(); mOverflow.performClick(); } CopyAnd in your styles.xml:<stylename="AppTheme"parent="android:Theme.Holo"><itemname="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item></style><stylename="Widget.ActionButton.Overflow"parent="@android:style/Widget.Holo.ActionButton.Overflow"><itemname="android:contentDescription">OVERFLOW</item></style>CopyfindViewsWithText requires API 14+, however the answer I linked, has a solution for lower APIs. Share You may like these postsCan't Prevent Keyboard Input On Android ChromeHow To Access Versioncode From Task In Gradle Experimental PluginCom.google.android.gms.common.api.apiexception: 16:How To Send Data To Server Post a Comment for "Programmatically Display Actionbar Overflow"
Post a Comment for "Programmatically Display Actionbar Overflow"