[問題] 新手求助
如有違板規 煩請提醒
============================
我是剛學習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設計畫面中都沒看到其他叉叉的錯誤警告
麻煩各位了 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.36.209.11
→
03/24 17:00, , 1F
03/24 17:00, 1F
推
03/24 17:27, , 2F
03/24 17:27, 2F
推
03/24 17:29, , 3F
03/24 17:29, 3F
→
03/24 17:33, , 4F
03/24 17:33, 4F
→
03/24 17:35, , 5F
03/24 17:35, 5F
推
03/24 17:36, , 6F
03/24 17:36, 6F
→
03/24 17:39, , 7F
03/24 17:39, 7F
→
03/24 17:43, , 8F
03/24 17:43, 8F
→
03/24 17:49, , 9F
03/24 17:49, 9F
→
03/24 17:51, , 10F
03/24 17:51, 10F
Eclipse 近期熱門文章
PTT數位生活區 即時熱門文章