The goal is to set cursor position of an EditText to 2, using setSelection(int).
Here's the excerpt from my RegisterActivity.java:
 UserEmail = (EditText) findViewById(R.id.register_email);
 UserEmail.setSelection(2); //cursor position
Here's the activity_register.xml:
<EditText
        android:id="@+id/register_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:inputType="textEmailAddress"
        android:background="@drawable/ab_transparent_example"
        android:padding="4dp"
        android:drawableStart="@drawable/ic_mail_outline_gray_24dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="17dp"
        android:layout_marginRight="17dp"/>
The app crashes when I use an int > 0 in setSelection(int), such as 2 in the code above.
Is there an alternative to that method in the java file? Is there a workaround inside the xml itself?
 
     
    