大家知道Menu功能菜單設計嗎?下面我們就給大家詳細介紹一下吧!
- package com.android.test;
-
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.widget.Toast;
-
- public class MenuDemo extends Activity {
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-
- // 創建菜單
- public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, 0, 0, "關於");
- menu.add(0, 1, 1, "退出");
- return super.onCreateOptionsMenu(menu);
- }
- //菜單響應
- public boolean onOptionsItemSelected(MenuItem item) {
- super.onOptionsItemSelected(item);
- &n