Android Menu

来源:互联网 发布:查看端口是否的命令 编辑:程序博客网 时间:2024/06/06 04:47

两种方式:

public boolean onCreateOptionsMenu(Menu menu)
中,
menu.add(Menu.NONE,Menu.FIRST+1,Menu.NONE,"La1"); menu.add(Menu.NONE,Menu.FIRST+2,Menu.NONE,"La2"); menu.add(Menu.NONE,Menu.FIRST+3,Menu.NONE,"La3");

或者自己写xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">    <item android:id="@+id/action_settings" android:title="@string/action_settings"        android:orderInCategory="100" app:showAsAction="ifRoom" />    <item android:id="@+id/action_add" android:title="Add"        android:orderInCategory="100" app:showAsAction="ifRoom" />    <item android:id="@+id/action_quary" android:title="Quary"        android:orderInCategory="100" app:showAsAction="ifRoom" /></menu>
然后在函数中找到
getMenuInflater().inflate(R.menu.menu_main,menu);

0 0
原创粉丝点击