(Deprecated) Fragment onOptionsItemSelected not being called

Same problems happened to me: onMenuItemSelected events didn’t get called in Fragment Searched google cann’t find a solution, and add onMenuItemSelected method in FragmentActivity doesn’t solve it. Finally resolve it by following reference to http://developer.android.com/guide/topics/ui/actionbar.html Note: If you added the menu item from a fragment, via the Fragment class’s onCreateOptionsMenu callback, then the system calls … Read more

What is the Default ActionBar Title Font Size?

The short one… $ grep ActionBar platforms/android-11/data/res/values/* leads to styles.xml: <style name=”TextAppearance.Widget.ActionBar.Title” parent=”@android:style/TextAppearance.Medium”> </style> <style name=”TextAppearance.Widget.ActionBar.Subtitle” parent=”@android:style/TextAppearance.Small”> </style> […] <style name=”TextAppearance.Medium”> <item name=”android:textSize”>18sp</item> </style> <style name=”TextAppearance.Small”> <item name=”android:textSize”>14sp</item> <item name=”android:textColor”>?textColorSecondary</item> </style>

Android action bar not showing overflow

If you want to show the three dots, irrespective of device menu button! then you can call this method in your application class’ onCreate method- private void makeActionOverflowMenuShown() { //devices with hardware menu button (e.g. Samsung Note) don’t show action overflow menu try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField(“sHasPermanentMenuKey”); if (menuKeyField != … Read more

what is exact difference between appbar, toolbar, actionbar ? and when to use them specifically?

Toolbar A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts. While an action bar is traditionally part of an Activity’s opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy. An … Read more

How to set custom ActionBar color / style?

You can define the color of the ActionBar (and other stuff) by creating a custom Style: Simply edit the res/values/styles.xml file of your Android project. For example like this: <resources> <style name=”MyCustomTheme” parent=”@android:style/Theme.Holo.Light”> <item name=”android:actionBarStyle”>@style/MyActionBarTheme</item> </style> <style name=”MyActionBarTheme” parent=”@android:style/Widget.Holo.Light.ActionBar”> <item name=”android:background”>ANY_HEX_COLOR_CODE</item> </style> </resources> Then set “MyCustomTheme” as the Theme of your Activity that contains the … Read more

actionbar up navigation with fragments

Implement OnBackStackChangedListener and add this code to your Fragment Activity. @Override public void onCreate(Bundle savedInstanceState) { //Listen for changes in the back stack getSupportFragmentManager().addOnBackStackChangedListener(this); //Handle when activity is recreated like on orientation Change shouldDisplayHomeUp(); } @Override public void onBackStackChanged() { shouldDisplayHomeUp(); } public void shouldDisplayHomeUp(){ //Enable Up button only if there are entries in the … Read more

Coordinator Layout with Toolbar in Fragments or Activity

As for me it sounds too weird to have appbar and toolbar in each fragment. So I’ve chosen to have single appbar with toolbar in activity. To solve that issue with CoordinatorLayout you will have to set different behaviour of your FrameLayout (or any other Layout) that supposed to hold fragments from each fragment that … Read more