我喜欢在按钮单击中为 edit_text 设置文本观察器。文本观察器应仅在单击按钮时起作用。我在按钮单击中使用了文本观察器代码。但它不是那样工作的,它会在编辑文本更改时触发。我还尝试了以下代码。也不行。
edt_zip.setImeOptions(EditorInfo.IME_ACTION_DONE);
edt_zip.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
if (btn_update_reader.getText().toString()
.equals("CANCEL UPDATE")) {
btn_update_reader.setText("UPDATE READER");
}
return true;
}
return false;
}
});