The text I received from the Android layout is not going in. Is there any other way?

Asked 2 years ago, Updated 2 years ago, 25 views

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")

Previously posted https://hashcode.co.kr/questions/10814/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%BD%94%EB%93%9C-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4-%ED%8A%95%EA%B8%B0%EB%8A%94-%EC%9D%B4%EC%9C%A0%EB%A5%BC-%EB%AA%B0%EB%9D%BC%EC%84%9C-%EC%A7%88%EB%AC%B8%EC%98%AC%EB%A6%BD%EB%8B%88%EB%8B%A4

android

2022-09-20 21:50

1 Answers

textView_total.setText(total); //The 89th line

It is thought that the error occurs because the total is not a String.


2022-09-20 21:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.