菜鸟有关问题

   阅读
初学者问题
初学android,第一个程序就有问题,就是显示几个button,但我运行看不到应该显示的button

Java code

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和strings.xml如下:
Java code

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>



我估计是main.xml的问题,怎么改啊


------解决方案--------------------
跟main.xml没关系,主要是Andriod模拟器的问题,需要点下面那一排中像O形状的按钮,才能点出菜单——
------解决方案--------------------
这个是menu,不是button,你要点menu键才有
阅读