Я пытаюсь получить ввод из поля EditText
в Android
и использовать его в другом методе, но ничего не происходит. Я не уверен, что ошибка в getInput
или в методе, который ее вызывает. Вот методы:
public String getUserInput() {
EditText userInput = findViewById(R.id.inputAnswer);
return userInput.getText().toString();
}
public void checkQuestion3() {
String name = getUserInput();
if (name.trim().equalsIgnoreCase("Class")) {
score += 1;
}
}
и текст редактирования в xml:
<EditText
android:id="@+id/inputAnswer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Your Answer"
android:inputType="text"
android:maxLength="15" />