在这里,我尝试添加 3 个文本视图的值,然后使用按钮 onClickListener() 在另一个文本视图中显示,但是每当我单击按钮时,每次获取,不幸的是,应用程序已停止并出现以下 Logcat 请问题并提供一些解决方案,Logcat 报告
10-13 17:48:40.440: E/Trace(703): error opening trace file:
No such file or directory (2)
10-13 17:48:41.080: D/dalvikvm(703):
GC_CONCURRENT freed 65K, 2% free 8362K/8519K, paused 35ms+30ms, total 214ms
10-13 17:48:41.080: D/gralloc_goldfish(703): Emulator without GPU emulation detected.
10-13 17:49:01.316: I/Choreographer(703): Skipped 31 frames!
The application may be doing too much work on its main thread.
10-13 17:50:16.511: I/Choreographer(703): Skipped 31 frames!
The application may be doing too much work on its main thread.
10-13 17:50:35.430: D/AndroidRuntime(703): Shutting down VM
10-13 17:50:35.430: W/dalvikvm(703): threadid=1:
thread exiting with uncaught exception (group=0x40a13300)
10-13 17:50:35.450: E/AndroidRuntime(703): FATAL EXCEPTION: main
10-13 17:50:35.450: E/AndroidRuntime(703): java.lang.NullPointerException
10-13 17:50:35.450: E/AndroidRuntime(703):
at com.suvendu.tutorial.cb.CheckBoxTutorialActivity$1.onClick
(CheckBoxTutorialActivity.java:88)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.view.View.performClick(View.java:4084)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.view.View$PerformClick.run(View.java:16966)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.os.Handler.handleCallback(Handler.java:615)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.os.Handler.dispatchMessage(Handler.java:92)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.os.Looper.loop(Looper.java:137)
10-13 17:50:35.450: E/AndroidRuntime(703):
at android.app.ActivityThread.main(ActivityThread.java:4745)
10-13 17:50:35.450: E/AndroidRuntime(703):
at java.lang.reflect.Method.invokeNative(Native Method)
10-13 17:50:35.450: E/AndroidRuntime(703):
at java.lang.reflect.Method.invoke(Method.java:511)
10-13 17:50:35.450: E/AndroidRuntime(703):
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-13 17:50:35.450: E/AndroidRuntime(703):
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-13 17:50:35.450: E/AndroidRuntime(703):
at dalvik.system.NativeStart.main(Native Method)
活动代码:-
Integer c;
Integer y;
Integer z;
Integer a;
btn_total_code=(Button)findViewById(R.id.btn_total);
btn_total_code.setOnClickListener(new Button.OnClickListener()
{
public void onClick (View v) {
c=Integer.parseInt(text_price_regular_code.getText().toString());
y=Integer.parseInt(text_price_regular_code.getText().toString());
z=Integer.parseInt(text_price_regular_code.getText().toString());
a=c+y+z;
text_total_code.setText(Integer.toString(a));
}
});