app:showAsActionandroid
它有三个可选项
1.always:老是显示在界面上
2.never:不显示在界面上,只让出如今右边的三个点中
3.ifRoom:若是有位置才显示,否则就出如今右边的三个点中app
android:showAsActionspa
这个属性可接受的值有:code
1.alaways:这个值会使菜单项一直显示在ActionBar上。blog
2.ifRoom:若是有足够的空间,这个值会使菜单显示在ActionBar上。it
3.never:这个值菜单永远不会出如今ActionBar是。io
4.withText:这个值使菜单和它的图标,菜单文本一块儿显示。class
When using the appcompat library, menu resources should refer to the showAsAction in the app: namespace, not the android: namespace. Similarly, when not using the appcompat library, you should be using the android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu. You should use AppCompatActivity with AppCompat Action bar and app:showAsAction; or Activity with android:showAsAction.
public class MainActivity extends AppCompatActivity {//像这样的AppCompatActivity 须要使用app:showAsAction .......... }
public class MainActivity extends Activity{ //像这样的Activity 须要使用android:showAsAction ......... }