由于Key有Down和Up事件,所以会执行两次。
class editTextOnKeyClickListener implements etOnKeyClickListener {
@Override
public boolean onKeyClick(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_ENTER&& event.getAction() == KeyEvent.ACTION_DOWN) {
InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
key = search_edit_text.getText().toString();
if (imm.isActive()) {
imm.hideSoftInputFromWindow(v.getApplicationWindowToken(),
0);
}
load_view.setVisibility(View.VISIBLE);
page = 0;
SearchBookAsyncTask task = new SearchBookAsyncTask(key,
load_view, view, myBookList, search_book_adapter, page,
null, null, 0, list, showList,bg);
task.execute();
}
return false;
}
}
android edittext 点击回车会响应两次的解决方案
原文地址:http://blog.csdn.net/woaic__/article/details/44901925