0
私はクライアントに登録するために私のアプリにフォームを持っています。そのフォームで私はYes
またはNo
を持っているConsent
ドロップダウンを持っています。私がしたかったのは、人がNo
を選択して登録を完了できない場合、Yes
を選択して次のアクティビティに進む必要があるということです。私のコードでは、ユーザーが何を選択したかにかかわらず、スティルはエラーメッセージを表示し、ユーザーは移動を許可しません。Android - Spinnerエラーメッセージを作成する
私はこのために使用されるコードは次のとおりです。セットアップ
Arrayアダプタ:
//set up for consent spinner
adapter = ArrayAdapter.createFromResource(this,
R.array.Register_array_consent, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mspinnerPatientConsent.setAdapter(adapter);
スピナーエラーが設定:
// Consent Spinner Error set up
Boolean no_error;
TextView errorText = (TextView)mspinnerPatientConsent.getSelectedView();
if (mspinnerPatientConsent.getSelectedItem().toString().contains("No"));{
errorText.setText("Patient Must Consent to Be Registered");
errorText.setError("");
}
if (mspinnerPatientConsent.getSelectedItem().toString().contains(" "));{
errorText.setText("Patient Must Consent to Be Registered");
errorText.setError("");
no_error = false;
}
を私は本当に新しいですそれはおそらく私が問題を見ることができない理由です。私は有用な入力を感謝します。ありがとうございました!
「if」ステートメントでこれを変更する必要がありますか? –
このコードはif文に入れる必要があります。私の編集した答えを見てください。 – rmdan
これは動作しませんでしたが、選択に関係なくエラーが表示されました –