ユーザーが数字を入力できる編集テキストを作成しました。私のアプリでは、ユーザーは送信ボタンをクリックして値を送信できます。
String st1=editText1.getText().toString();
int tempVal1=Integer.parseInt(st);
String st2=editText2.getText().toString();
int tempVa2=Integer.parseInt(st);
String st3=editText2.getText().toString();
int tempVal3=Integer.parseInt(st);
しかし、ここで私の問題は、ユーザーが最初の editText に値を入力せず、2 番目と 3 番目のみを入力して送信した場合、tempVal1 の値は 0 になるはずです。任意のデータを持っています。この例外を回避し、それぞれの編集テキストに何も入力しない場合に tempVal 0 を維持するにはどうすればよいですか?
この行を追加すると int x=Integer.valueOf(editText.getText());
、次のエラーが発生します。なんで?The method valueOf(String) in the type Integer is not applicable for the arguments (Editable)
私の疑問を明確にしてください。