3

I'm making an android application and I have an EditText element where, once you press enter in that field, text elsewhere on the same page is updated, though you cannot immediately see it because the keyboard is in the way. In short, is there a way to have the keyboard go away (i.e. have the text editor de-select itself when enter is pressed)?

CaptainForge
  • 1,245
  • 4
  • 20
  • 42
  • You want the keyboard to disappear when you finish entering the text in `EditText`? – joao2fast4u Jul 17 '14 at 00:52
  • If your main problem is hiding the soft keyboard, check out this [question thread](http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard) – Sound Conception Jul 17 '14 at 00:54

1 Answers1

2

You just have to set your EditText as singleLine and enable the IMEAction Done, like this:

       <EditText
        android:id="@+id/myEditText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:gravity="center"
        android:singleLine="true"
        android:imeActionLabel="Done"
        android:imeOptions="actionDone"
        android:textColor="@android:color/black"
        android:textSize="16sp" />
joao2fast4u
  • 6,574
  • 5
  • 25
  • 41