請幫助我在嘗試將TextView文本設置爲「測試」時很容易出錯。設置TextView文本時出錯
以下是錯誤:
02-23 21:25:43.610 20928-20928/com.example.edward.datepickertest2 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.edward.datepickertest2, PID: 20928 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at com.example.edward.datepickertest2.MainActivity$1.onClick(MainActivity.java:28) at android.view.View.performClick(View.java:5204) at android.view.View$PerformClick.run(View.java:21153) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
它很明顯地說你正在將值設置爲null(TextView)。它沒有被初始化。所以請發佈您的代碼,以便我們可以幫助您。 –
這裏的代碼 https://www.dropbox.com/s/446mp92ymwbd0j0/TextView%20Error.txt?dl=0 – AgentEddie99
在這裏發佈的代碼不共享鏈接的代碼.. – rafsanahmad007