How does Android get the exact location of any text in the text entered by EditText?

how does Android get the exact location of any text in the text entered by EditText?
use edittext.setSelection (edittext.getText () .length) to get only the position of the last character and how to get the position of any text in it. For example: edittetx input text abcdtghjk, through the finger click b, how to return to the current text position?

Apr.16,2021

take a look at this?

https://blog.csdn.net/u011840.

use this method to disable popping up of the system keyboard, call the custom keyboard, and return false, in the setOnTouchListener event of editext otherwise the cursor cannot be moved to the position where the finger is clicked.
private void showEditText (EditText edit) {

if (android.os.Build.VERSION.SDK_INT <= 10) {//4.0
    edit.setInputType(InputType.TYPE_NULL);
} else {
    this.act.getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    try {
        Class<EditText> cls = EditText.class;
        Method setShowSoftInputOnFocus;
        setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus",
                boolean.class);
        setShowSoftInputOnFocus.setAccessible(true);
        setShowSoftInputOnFocus.invoke(edit, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

Menu