8
textView.setTextIsSelectable(true);

requires min API level 11.

Is there anyway to support it from API level 8+ ?

yajnesh
  • 2,089
  • 1
  • 23
  • 36

3 Answers3

2

There are some methods described here & here, but there's probably no way to do this to achieve same functionality

Community
  • 1
  • 1
Sam
  • 1,652
  • 17
  • 25
1

Create a new class by extending TextView class and override setTextIsSelectable

        @SuppressLint("NewApi")
public void setTextIsSelectable(boolean selectable) {
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
        super.setTextIsSelectable(true);
    else
    {   
        super.setLongClickable(true);
        super.setOnLongClickListener(getSelectableLongClick());
        super.setOnTouchListener(getSelectableOnTouch());
    }
}
Vishal Vijay
  • 2,518
  • 2
  • 23
  • 45
1

I'm using EditText with the attributes:

android:inputType="none"
android:background="@null"

And do this in code:

editText.setKeyListener(null);

Which makes EditText non-editable but still with select and copy functionality. The only drawback is the visible cursor when the widget is focused. I can't set android:cursorVisible to false because it hides the selection background together with the cursor.

Viachaslau Tysianchuk
  • 1,680
  • 19
  • 22