初学者问题
初学android,第一个程序就有问题,就是显示几个button,但我运行看不到应该显示的button
package com.misoo.ex01;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;public class ex01 extends Activity { public static final int ADD_ID = Menu.FIRST; public static final int DELETE_ID = Menu.FIRST + 1; public static final int EXIT_ID = Menu.FIRST + 2; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, ADD_ID, 0, R.string.menu_add); menu.add(0, DELETE_ID, 1, R.string.menu_delete); menu.add(0, EXIT_ID, 2, R.string.menu_exit); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case ADD_ID: setTitle("Insert..."); break; case DELETE_ID: setTitle("Delete..."); break; case EXIT_ID: finish(); break; } return super.onOptionsItemSelected(item); }}
main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ></LinearLayout>strings.xml<?xml version="1.0" encoding="utf-8"?><resources><string name="app_name">ex01</string><string name="menu_add">Add Item</string><string name="menu_delete">Del Item</string><string name="menu_exit">Exit</string></resources>