Arrow positioning the cursor to the last character of the text field in EditText. - Android User Interface

Android examples for User Interface:EditText

Description

Arrow positioning the cursor to the last character of the text field in EditText.

Demo Code


//package com.java2s;
import android.text.Editable;
import android.text.Selection;
import android.widget.EditText;

public class Main {
    /**/*from  w ww  . j a v  a2  s.  com*/
     * Arrow positioning the cursor to the last character of the text field.
     * 
     * @param txtField
     */
    public final static void setFocusToLastPosition(EditText txtField) {
        int pos = txtField.getText().length();
        Editable editable = (Editable) txtField.getText();
        Selection.setSelection(editable, pos);
    }
}

Related Tutorials