package masr.helloworld;import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;public class HelloworldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView myTextView=(TextView)findViewById(R.id.myTextView);
        Button MyButton=(Button)findViewById(R.id.myButton);
        myTextView.setText("我的第一个Activity");
        MyButton.setText("future");
    }
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
     if(item.getItemId()==1)
     {
     finish();
     }
return super.onOptionsItemSelected(item);
}
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0,1,1, R.string.exit);
menu.add(0,2,2,R.string.about);
return super.onCreateOptionsMenu(menu);
}
}为什么点menu会报错 在线等!!! 我刚入门!

解决方案 »

  1.   

    急啊.. 随便告诉一个怎么看ecplise logcat错误的方法.. 用了过滤器还是那么大一堆... 主要看什么!!!
      

  2.   

    onOptionsItemSelected
    return false;试试
      

  3.   

    我测试了,没问题啊。
    要不你试试
    private static final int MENU_EXIT=Menu.FIRST;
    private static final int MENU_ABOUT=Menu.FIRST+1;menu.add(0,MENU_EXIT,1, R.string.exit);
    menu.add(0,MENU_ABOUT,2,R.string.about)