textView.setTextIsSelectable(true);
requires min API level 11.
Is there anyway to support it from API level 8+ ?
There are some methods described here & here, but there's probably no way to do this to achieve same functionality
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With