我正在尝试从 textwatcher 更改 imeOptions,在检测到 edittext 上的“@”符号时,我需要将其 imeOptions 从“Go”更改为“Done”。请指教。
etSample.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if ((charSequence+"").contains("@")){
etSample.setBackgroundColor(Color.BLACK);
etSample.setTextColor(Color.WHITE);
etSample.setImeOptions(EditorInfo.IME_ACTION_NEXT);
etSample.requestFocus();
}else {
etSample.setBackgroundColor(Color.WHITE);
etSample.setTextColor(Color.BLACK);
etSample.setImeOptions(EditorInfo.IME_ACTION_DONE);
etSample.requestFocus();
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
这不起作用(它总是会显示完成)