Android 编辑可以重新聚焦的文本
我想将我的编辑文本设置为始终聚焦,当我输入内容并按enter键时,它将清除并再次恢复聚焦,并且可以再次输入 您可以捕获EditText的enter键事件,从中提取文本,然后将文本设置为“” 在这里Android 编辑可以重新聚焦的文本,android,Android,我想将我的编辑文本设置为始终聚焦,当我输入内容并按enter键时,它将清除并再次恢复聚焦,并且可以再次输入 您可以捕获EditText的enter键事件,从中提取文本,然后将文本设置为“” 在这里 EditText et; ArrayList<String> input = new ArrayList<String>(); // I am not sure how // you want to save the strings, but this is a go
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;
}
}
});
...
edittet;
ArrayList输入=新建ArrayList();//我不知道怎么做
//您希望保存字符串,但这是一个好方法。
...
@凌驾
创建时的公共void(Bundle sIS){
et=(EditText)findViewById(R.id.et);//在此处填写您的id
et.setOnEditorActionListener(新的OnEditorActionListener(){
@凌驾
公共布尔onEditorAction(TextView arg0,
int actionId,KeyEvent事件){
actionId=(actionId&EditorInfo.IME\u MASK\u ACTION);
交换机(actionId){
案例EditorInfo.IME\u操作\u完成:
case EditorInfo.IME\u ACTION\u GO:
案例编辑信息.IME\u操作\u下一步:
if(etAddLike.getText().length()>0){
add(et.getText().toString());
etAddLike.setText(“”);
}
返回true;
违约:
返回false;
}
}
});
...
如果答案有效,不要忘记接受它。当您想集中精力解决它时,请调用
edittext.requestFocus();
“EditorInfo.IME\u ACTION\u ENTER”中的问题