due to the different hardware situation, in the absence of physical menu keys on the phone, Actionbar overflow button will not show the situation, The value of the Shaspermanentmenukey static variable in the Viewconfiguration class can be modified by reflection forever false, the system is based on this variable value to determine whether the phone has a physical menu key, the code is as follows:
@Override
protected void OnCreate (Bundle savedinstancestate) {
...
setoverflowshowingalways ();
}
private void Setoverflowshowingalways () {
try {
viewconfiguration config = viewconfiguration.get (this);
Field Menukeyfield = ViewConfiguration.class.getDeclaredField ("Shaspermanentmenukey");
menukeyfield.setaccessible (TRUE);
Menukeyfield.setboolean (config, false);
} catch (Exception e) {
E.printstacktrace ();
}
}
The overflow button of Actionbar is forced to display under Android