2

I have an EditText and I want programatically enter in "text selection mode" indicated by CursorControllers (handles), for example when user long press on EditText.

Any examples or suggestions will highly appreciated.

Corje
  • 158
  • 7

2 Answers2

2

Try

    editText.onTextContextMenuItem(android.R.id.startSelectingText);

for pre-Honeycomb versions and

    editText.onTouchEvent(MotionEvent.obtain(/* FakeLongClick */));

for Honeycomb and newer.

I'm not familiar with motion events, but i think this should work if you are able to simulate a long click event...

codebold
  • 146
  • 1
  • 10
  • Here's a helpful Q&A about creating MotionEvents: https://stackoverflow.com/questions/5867059/android-how-to-create-a-motionevent – Evan Jan 30 '18 at 16:10
-1

you can paste some text to EditText by...

     <EditText
    android:id="@+id/et_link"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Link" /> 

"Link" will apeear in EditText window

timonvlad
  • 1,046
  • 3
  • 13
  • 31