spa*_*kli 3 android focus onkeypress android-edittext
因此,如果在 edittext gotovinaEdit 中按下 Enter 键,我想将焦点切换到 edittext karticeEdit。到目前为止,这是我的代码,但它不起作用
final EditText gotovinaEdit = (EditText) vieww.findViewById(R.id.gotovinaEdit);
final EditText karticeEdit = (EditText) vieww.findViewById(R.id.karticeEdit);
gotovinaEdit.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) && (i == KeyEvent.KEYCODE_ENTER)) {
gotovinaEdit.clearFocus();
karticeEdit.requestFocus();
return true;
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
编辑:弄清楚了,只需添加 android:singleLine="true",希望这对某人有帮助
| 归档时间: |
|
| 查看次数: |
2242 次 |
| 最近记录: |