android 监听软键盘 回车键

mPassword = (EditText) mView.findViewById(R.id.login_edittext_userpassword);

mPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {


@Override

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {


if(actionId == 0){

/*隐藏软键盘*/

InputMethodManager imm = (InputMethodManager) v

.getContext().getSystemService(

Context.INPUT_METHOD_SERVICE);

if (imm.isActive()) {

imm.hideSoftInputFromWindow(

v.getApplicationWindowToken(), 0);

}


checkLogin();

return false;//这里要return false 否则会密码无效

}

return false;

}

});


你可能感兴趣的:(android,软键盘,回车键)