Input() function
public void input() {
editText_pay = (EditText) findViewById(R.id.editText_pay);
editText_overworkpay = (EditText) findViewById(R.id.editText_overworkpay);
editText_normworktime = (EditText) findViewById(R.id.editText_normworktime);
editText_startdate = (EditText) findViewById(R.id.editText_startdate);
editText_enddate = (EditText) findViewById(R.id.editText_enddate);
editText_sun = (EditText) findViewById(R.id.editText_sun);
editText_mon = (EditText) findViewById(R.id.editText_mon);
editText_tue = (EditText) findViewById(R.id.editText_tue);
editText_wed = (EditText) findViewById(R.id.editText_wed);
editText_thr = (EditText) findViewById(R.id.editText_thr);
editText_fri = (EditText) findViewById(R.id.editText_fri);
editText_sat = (EditText) findViewById(R.id.editText_sat);
spinner_week1 = (Spinner)findViewById(R.id.spinner_week1);
week1 = spinner_week1.getSelectedItem().toString();
spinner_endOfMonth = (Spinner) findViewById(R.id.spinner_endOfMonth);
varEndOfMonth = Integer.parseInt(spinner_endOfMonth.getSelectedItem().toString());
week[0] = Integer.parseInt(editText_sun.getText().toString());
week[1] = Integer.parseInt(editText_mon.getText().toString());
week[2] = Integer.parseInt(editText_tue.getText().toString());
week[3] = Integer.parseInt(editText_wed.getText().toString());
week[4] = Integer.parseInt(editText_thr.getText().toString());
week[5] = Integer.parseInt(editText_fri.getText().toString());
week[6] = Integer.parseInt(editText_sat.getText().toString());
pay = Integer.parseInt(editText_pay.getText().toString());
overworkpay = Integer.parseInt(editText_overworkpay.getText().toString());
normworktime = Integer.parseInt(editText_normworktime.getText().toString());
startdate = Integer.parseInt(editText_startdate.getText().toString());
enddate = Integer.parseInt(editText_enddate.getText().toString());
} //put values into variables so that they can be used.
setText location
switch (rgroup.getCheckedRadioButtonId()){
case R.id.radioButton_bytime:
calculateWorktimeByTime();
textView_total.setText(total); //The 89th line
break;
case R.id.radioButton_bymult:
calculateWorktimeByMult();
textView_total.setText(total); //The 93rd line
break;
}
Error code
E/mple.calculato: Invalid ID 0x00000000.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.calculator, PID: 12500
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:367)
at android.widget.TextView.setText(TextView.java:6370)
at com.example.calculator.MainActivity$1.onClick(MainActivity.java:89)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process: Sending signal. PID: 12500 SIG: 9
Last time, I uploaded the entire code and received an answer, but there was a place where I missed it. After that, I corrected the code in question, but it still doesn't work with the error below. I'm posting a question because I don't know if it's input or output because I don't know the error code. (It seems more likely that you can't input it as a variable, but if that's the problem, I wonder if there's another way to get the xml value.)
(Note that you specified all EditText in the xml file as android:inputType = "number")
android
textView_total.setText(total); //The 89th line
It is thought that the error occurs because the total is not a String.
© 2024 OneMinuteCode. All rights reserved.