-3
여기
코드이지만, 내가 응용 프로그램을 시작할 때 그것은 안드로이드 모니터 결과를오류는 다음에 수학을하고 결과를 보여
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ImageButton imageButton = (ImageButton) findViewById(R.id.imageButton);
ImageButton imageButton2 = (ImageButton) findViewById(R.id.imageButton2);
ImageButton imageButton3= (ImageButton) findViewById(R.id.imageButton3);
ImageButton imageButton4 = (ImageButton) findViewById(R.id.imageButton4);
ImageButton imageButton5 = (ImageButton) findViewById(R.id.imageButton5);
ImageButton imageButton6 = (ImageButton) findViewById(R.id.imageButton6);
ImageButton imageButton7 = (ImageButton) findViewById(R.id.imageButton7);
ImageButton imageButton8 = (ImageButton) findViewById(R.id.imageButton8);
ImageButton imageButton9 = (ImageButton) findViewById(R.id.imageButton9);
final EditText editText = (EditText) findViewById(R.id.editText);
EditText editText2 = (EditText) findViewById(R.id.editText2);
EditText editText3 = (EditText) findViewById(R.id.editText3);
final TextView textView50 = (TextView)findViewById(R.id.textView50);
//here where the android monitor says it error
final int dayNumber = Integer.parseInt(editText.getText().toString());
editText2.getText();
editText3.getText();
imageButton3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int a = dayNumber * 4;
textView50.setText(String.valueOf(a));
}
});
충돌하고 여기
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ahmednageeb.com.yourageinotherplanets, PID: 19858
java.lang.RuntimeException: Unable to start activity ComponentInfo{ahmednageeb.com.package/ahmednageeb.com.package.Main2Activity}: java.lang.NumberFormatException: Invalid int: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
Caused by: java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at ahmednageeb.com.package.Main2Activity.onCreate(Main2Activity.java:40)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
07-31 19:45:56.587 19858-19858/ahmednageeb.com.package I/Process: Sending signal. PID: 19858 SIG: 9
빈 문자열을 정수로 구문 분석하려고합니다. Do not do –
@ circket_007 답변을 많이 주셔서 감사합니다. 자바를 처음 접 하시며 더 많은 것을 설명해 주실 수 있습니다. –
그건 대답이 아닌 대답입니다. 아래의 실제 답변을 참조하고 문제가 해결되면 옆에있는 체크 표시를 사용하십시오. –