如有违板规 烦请提醒
============================
我是刚学习eclipes的新手
安装完主程式 开启第一个内建的app
成功输出apk到手机 可以正常开启那个hello world的原始app
开始学习第二步
制作button来改变"hello world"文字
完全照教学的步骤输入程式码
关键内容如下
==========================================================
MyButton=(Button)findViewById(R.id.button1);
tv1=(TextView)findViewById(R.id.textview1);
MyButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
tv1.setText("测试测试");
}}
);
==========================================================
但不管怎么做 一开启app就会跳 unfortunately xxx has stopped
以下是错误log 但我看不懂.. 请大家帮我看看出了什么问题
03-24 04:41:22.210: W/dalvikvm(911): threadid=1: thread exiting with uncaught
exception (group=0xb4a89ba8)
03-24 04:41:22.220: E/AndroidRuntime(911): FATAL EXCEPTION: main
03-24 04:41:22.220: E/AndroidRuntime(911): Process: hhhr.ff, PID: 911
03-24 04:41:22.220: E/AndroidRuntime(911): java.lang.RuntimeException: Unable
to start activity ComponentInfo{hhhr.ff/hhhr.ff.MainActivity}:
java.lang.NullPointerException
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.os.Looper.loop(Looper.java:136)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-24 04:41:22.220: E/AndroidRuntime(911): at
java.lang.reflect.Method.invokeNative(Native Method)
03-24 04:41:22.220: E/AndroidRuntime(911): at
java.lang.reflect.Method.invoke(Method.java:515)
03-24 04:41:22.220: E/AndroidRuntime(911): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-24 04:41:22.220: E/AndroidRuntime(911): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-24 04:41:22.220: E/AndroidRuntime(911): at
dalvik.system.NativeStart.main(Native Method)
03-24 04:41:22.220: E/AndroidRuntime(911): Caused by:
java.lang.NullPointerException
03-24 04:41:22.220: E/AndroidRuntime(911): at
hhhr.ff.MainActivity.onCreate(MainActivity.java:24)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.Activity.performCreate(Activity.java:5231)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-24 04:41:22.220: E/AndroidRuntime(911): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-24 04:41:22.220: E/AndroidRuntime(911): ... 11 more
ps.在eclipes设计画面中都没看到其他叉叉的错误警告
麻烦各位了 谢谢