android set hidden the keybord on press enter (in a EditText)
Posted
by user119333
on Stack Overflow
See other posts from Stack Overflow
or by user119333
Published on 2010-03-12T17:24:14Z
Indexed on
2010/03/12
17:37 UTC
Read the original article
Hit count: 295
Hi,
When my user press "ENTER" on the virtual android "user validate entry!" keybord my keybord stay visible ! (Why?)
Here my Java code...
private void initTextField() { entryUser = (EditText) findViewById(R.id.studentEntrySalary); entryUser.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
userValidateEntry();
return true;
}
}
return true;
}
}); }
private void userValidateEntry() { System.out.println("user validate entry!"); }
... here my View
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:id="@+id/studentEntrySalary" android:text="Foo" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Maybe something wrong on my virtual device ?
© Stack Overflow or respective owner