7

I have only one EditText in my Activity and I want it to hide the blinking cursor once the input is done - either the focus is switched or user presses Done - in other words, as the input keyboard disappears.
Here's the code for the EditText.

<EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="-4dp"
                android:id="@+id/editText"
                android:textColor="@color/theme2"
                android:textSize="15dp"
                android:singleLine="true"
                android:maxLines="1"
                android:background="@android:color/transparent"
                android:imeOptions="actionDone"
                android:nextFocusUp="@id/editText"
                android:nextFocusLeft="@id/editText"/>
ai.
  • 87
  • 1
  • 1
  • 8
  • http://stackoverflow.com/questions/3425932/detecting-when-user-has-dismissed-the-soft-keyboard – Tobrun Nov 10 '14 at 19:37

2 Answers2

9

To stop the cursor from blinking in an EditText, simply use this line:

editText.setCursorVisible(false);

That's it.

Alessandro Roaro
  • 4,665
  • 6
  • 29
  • 48
1

I would simply

editText.clearFocus();
Aleksandarf
  • 373
  • 4
  • 8
  • Could you please provide more information? Like where he would call this method, in which part of this program... – woliveirajr Apr 14 '16 at 12:50