效果展示:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/80495dacaefd56221ef3396d07eecd0c.png)
定义菜单控件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/more1_item" android:title="123" />
<item android:id="@+id/more2_item" android:title="456" />
<item android:id="@+id/more3_item" android:title="789" />
>
</menu>
java文件:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu1, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.more1_item:
break;
case R.id.more2_item:
break;
case R.id.more3_item:
break;
}
return true;
}