要求:
1.设置“打开”、“关闭”和“退出”三个菜单项的菜单。
2.当单击“打开“菜单项时,使用Log.i显示”文件已打开“
3.当单击“关闭“菜单项时,使用Log.i显示”文件已关闭“
4.当单击“打开“菜单项时,使用Toast显示”确定要退出吗?“
方法一:
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="长时间点这"/>
</LinearLayout>
menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item