Shane Duffy
Shane Duffy

Reputation: 1147

How to prevent custom dialog from blinking cursor on first EditText inside of it

I am creating a custom Dialog window but my problem is when the dialog first launches it automatically begins flashing the cursor on the FIRST EditText in the LinearLayout that defines the structure of the dialog. The keyboard does not appear, but the first EditText always has this blinking cursor on it.

I attempted to use the RequestFocus() function on a TextView within the dialog that cannot be edited, but the blinking cursor remains on the first EditText in the dialog.

If anyone has any advice or solutions to solving this problem, that would be great.

Upvotes: 0

Views: 592

Answers (2)

Joshua
Joshua

Reputation: 6241

If you want to stop EditText from gaining focus at startup, add these two lines to parent layout (e.g. LinearLayout).

android:focusable="true" 
android:focusableInTouchMode="true"

Upvotes: 2

DsD
DsD

Reputation: 1121

Use either XML attribute or Java function-

xml:

android:cursorVisible="false" 

Java function:

setCursorVisible(false)

Upvotes: 2

Related Questions