我想将我的editText设置为始终对焦,当我输入内容并按下输入键时,它将清除并重新获得焦点并可以再次输入。
答案 0 :(得分:1)
您可以捕获EditText的回车键事件,从中提取文本,然后将文本设置为“”。
这是;
EditText et;
ArrayList<String> input = new ArrayList<String>(); // I am not sure how
// you want to save the strings, but this is a good way.
...
@Override
public void onCreate(Bundle sIS){
et = (EditText)findViewById(R.id.et); // fill in your id here
et.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0,
int actionId, KeyEvent event) {
actionId = (actionId & EditorInfo.IME_MASK_ACTION);
switch (actionId){
case EditorInfo.IME_ACTION_DONE:
case EditorInfo.IME_ACTION_GO:
case EditorInfo.IME_ACTION_NEXT:
if (etAddLike.getText().length() > 0){
input.add(et.getText().toString());
etAddLike.setText("");
}
return true;
default:
return false;
}
}
});
...
如果有效,请不要忘记接受答案。
答案 1 :(得分:0)
当您想要关注它时,请致电edittext.requestFocus();