Last Updated: February 25, 2016
·
657
· wannabegeekboy

Removing autofocus when UI is rendered

Problem :

I had two editTexts and a Button

When I give setContent View by default the Cursor blinks in the either of the EditTexts but I need to remove the Cursor Blinking in the Screen when the UI is loaded initially and the Cursor needs to appear as the User clicks on the EdiText.

Solution : After much of a struggle the solution is create a Linear Layout on top of the EditText and code is as below

<LinearLayout
android:id="@+id/dummyLayout"
android:layoutwidth="0px"
android:layout
height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />

and specifiy the below code ,

android:nextFocusLeft="@id/emailid"
android:nextFocusUp="@id/emailid"

for the editTexts. It will solve the above Issue. and programtaically give a requestFocus call in the onCreate after rendering the UI.