Search code examples
androidandroid-layoutandroid-activity

Not able to select text in Edittext in Android on longclick?


I am trying to select text in Edittext for showing options of copy,paste but it is not selecting text on long press.

 <FrameLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<EditText
    android:id="@+id/et_extractedText"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textIsSelectable="true"
    android:layout_gravity="top|center"
    android:gravity="start"
    android:hint="@string/st_etHint"
    android:inputType="textMultiLine"
    android:scrollbars="vertical"
    android:typeface="monospace" />

    </FrameLayout>

I am using Android studio and build tools version 21.1.2.


Solution

  • Your code is working in my phone i am using micromax untie 2.

    You have hint in you edittext so its showing hint not text, Are you testing without typing anything into editText if that so then its just a hint and on doing long press on hint it will just show a paste option or may be dont show anything.