textView.setTextIsSelectable(true);
requires min API level 11.
Is there anyway to support it from API level 8+ ?
textView.setTextIsSelectable(true);
requires min API level 11.
Is there anyway to support it from API level 8+ ?
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());
}
}
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.