From b821157b9f0f9a2b5479fbdf9a2bb75d287892c9 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 16 Mar 2012 19:58:08 +0100 Subject: Make various text widgets selectable on sufficiently recent Android versions. --- src/org/madore/android/unicodeMap/UnicodeMapActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/org') diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java index aecea78..1358246 100644 --- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java +++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java @@ -27,6 +27,17 @@ import android.app.ProgressDialog; public final class UnicodeMapActivity extends ListActivity { + protected static void textMakeSelectableIfPossible(TextView text) { + // .setTextIsSelectable() method is only available on Android + // Honeycomb (API 11) and later. + try { + java.lang.reflect.Method m = TextView.class.getMethod("setTextIsSelectable", new Class[] { boolean.class }); + m.invoke(text, true); + } catch (Exception e) { + // Ignore + } + } + protected UnicodeDatabase db; protected ListView lv; protected ClipboardManager cmgr; @@ -313,6 +324,7 @@ public final class UnicodeMapActivity extends ListActivity { TextView text; text = (TextView) dialog.findViewById(R.id.detailsLabel); text.setText(itch.getLabel()); + textMakeSelectableIfPossible(text); text = (TextView) dialog.findViewById(R.id.encodingLabel); StringBuilder s = new StringBuilder(); Formatter fmt = new Formatter(s); @@ -326,6 +338,7 @@ public final class UnicodeMapActivity extends ListActivity { for ( int i=0 ; i