现在尝试使用此代码,但在按Enter键时仍保持空值?任何人都可以建议一个避免这种情况的解决方案吗?
editext.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey (View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode==KeyEvent.KEYCODE_ENTER) {
if ("test1".equalsIgnoreCase(editext.getText().toString())) {
but4.performClick();
}
}
else if ("test2".equalsIgnoreCase(editext.getText().toString())) {
but5.performClick();
}
if ("test5".equalsIgnoreCase(editext.getText().toString())) {
but6.performClick();
}
if ("test7".equalsIgnoreCase(editext.getText().toString())) {
but7.performClick();
}
if (editext.getText().toString() != null){
testwrong.seText("wrong");
}
return true;
}
});