前言
当新建android工程后,发现原来使用的ActionBar的屏幕右上角的三个点不再出现了(如图中3),它是因为什么原因不在出现了呢?如果不是我自己的原因,那怎么才能搞出来。这个问题通过下面的方式已经得到了解决。
1. 为什么这个菜单键(三点)会不见了?
大概意思也就是说安卓也在不断地进化中,有些东西可能被慢慢替代掉,从 Android 3.0(API 级别 11)开始,采用 Android 技术的设备不必再提供一个专用“菜单”按钮。可以参考sHasPermanentMenuKey()方法的源码解释:
Report if the device has a permanent menu key available to the user.
As of Android 3.0, devices may not have a permanent menu key available.
Apps should use the action bar to present menu options to users.
However, there are some apps where the action bar is inappropriate
or undesirable. This method may be used to detect if a menu key is present.If not, applications should provide another on-screen affordance to access functionality
2.怎么才能搞出来菜单键的功能呢?
关键点:在onCreate()方法中添