Mostrando entradas con la etiqueta menu. Mostrar todas las entradas
Mostrando entradas con la etiqueta menu. Mostrar todas las entradas

lunes, 23 de septiembre de 2013

Show ActionBar items within fragments

To enable OnCreateOptionsMenu, onPrepareOptionsMenu, onOptionsItemSelected, in fragment, you have to call setHasOptionsMenu within the fragment’s onCreate() method:
setHasOptionsMenu(true);

lunes, 10 de junio de 2013

Enable "More" button on action bar

By default in "pure android" devices you can see at right, in action bar, three gray dots to open the overflow menu. This menu is open in other devices by the hardware button menu.

Those devices with hardware button hide the action bar button.

Sometimes, project managers and clients without any idea about design encourage to us to enable this option in action bar, I am not recommending this feature, if there is no button in action bar is for one reason, it is because the hardware button exists, but if after talking with your pm or your client he is still blind, ok, this is the hack.

Again from Stackoverflow

public class MyApplication extends Application {
 
 @Override
 public void onCreate() {
  super.onCreate();
  
  getOverflowMenu();
 }
 
 protected void getOverflowMenu() {

      try {
         ViewConfiguration config = ViewConfiguration.get(this);
         Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
         if(menuKeyField != null) {
             menuKeyField.setAccessible(true);
             menuKeyField.setBoolean(config, false);
         }
     } catch (Exception e) {
         e.printStackTrace();
     }
 }

}