Android: textisselectable not working in TYPE_SYSTEM_ALERT window

I am adding a TextView to a floating window with the android:textisselectable .

 mWindowManager.addView(textView, params); 

Everything works fine, but I canโ€™t copy the text during long printing. The weird part is that it works great on the Galaxy Tab, but not on any other 5-inch phones that I have.

+5
source share
1 answer

I think this is a version issue. The Galaxy Tab has a version larger than Honeycomb, while the 5-inch screen can be cellular or lower.

Try this code:

 TextView textView; String stringToBeExtracted; int startingIndex=textView.getSelectionStart(); int endingIndex=textView.getSelectionEnd(); stringToBeExtracted = stringYouExtracted.subString(startingIndex, endingIndex); if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(stringToBeExtracted); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Text Copied", stringToBeExtracted); clipboard.setPrimaryClip(clip); } 
+2
source

Source: https://habr.com/ru/post/1236004/


All Articles