How to get initial cursor position on right of displayed text
<p>This should be simple but I have tried about a dozen things here in stackoverflow on the topic and they either do nothing or crash.</p>

<p>I have a edittext field that starts with the last entry, like "12" and I want the initial cursor to be to the right of the 2 and it always starts to the left of the 1.  That would be fine if there was a del key but with only a back key on the keyboard, the user must manually re-position the cursor before typing over the old text.  There are several fields and he most likely wants to leave most of them alone.  What I want if he wants to just edit the second field to have him hit "next" "bs", "bs", "45", "next", "done".  this way he doesn't have to position the cursor at all.</p>

<p>------------UPDATE----------------------</p>

<p>Here is the main file</p>

<pre><code>package com.example.test;
import android.os.Bundle;
import android.app.Activity;
import android.widget.EditText;


public class MainActivity extends Activity {
    static EditText edit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edit = (EditText) findViewById(R.id.edit);
        edit.setSelection(edit.getText().toString().length());
    }
}
</code></pre>

<p>and here is the xml</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" &gt;

&lt;EditText
    android:id="@+id/edit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="60dp"
    android:text="12"
    android:nextFocusDown="@+id/textView4"
    android:inputType="number"
    android:ellipsize="end"
    android:gravity="right"
    android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

&lt;TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/edit"
    android:layout_alignBottom="@+id/edit"
    android:layout_toRightOf="@+id/edit"
    android:text=":"
    android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

&lt;EditText
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignBottom="@+id/textView3"
    android:layout_toRightOf="@+id/textView3"
    android:text="00"
    android:inputType="number"
    android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
</code></pre>

<p></p>
