No cursor in editText under Honeycomb

I have an application that uses internal ime (this means that ime is just the code inside the application, not the true ime). I use this ime panel to enter / edit editText. Everything works fine until Froyo (I have not tested under Gingerbread). However, on the honeycombs I can enter text and edit it, but the cursor or text is not displayed. Does anyone know how to get around this? I would prefer not to fork my code on a special version of Honeycomb to fix this problem.

I explicitly set the xml element cursorVisible to true and then set it to true using setCursorVisible in the code, but that doesn't help.

Thanks!

+6
source share
2 answers

Add these attributes to your EditText to make the flickering cursor black:

android:textColor="#000000" android:textCursorDrawable="@null" 

This is necessary if you use the Holo theme. From: fooobar.com/questions/18125 / ...

+7
source

You can try the snapshot below.

 public static void setCursorVisible(EditText editText, Context context) { editText.setCursorVisible(true); // sdk // http://developer.android.com/guide/topics/manifest/uses-sdk-element.html if (android.os.Build.VERSION.SDK_INT >= 12) {// Android 3.1.x API12 // HONEYCOMB_MR1 String filedNameString = "mCursorDrawableRes"; // mCursorDrawableRes Class<? extends EditText> editTextClass = editText.getClass(); Class<? extends TextView> textViewClass = null; if (editTextClass != null) { textViewClass = (Class<? extends TextView>) editTextClass .getSuperclass(); } if (textViewClass != null) { Field mCursorDrawableField = null; try { mCursorDrawableField = textViewClass .getDeclaredField(filedNameString); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block Log.i(TAG, "NoSuchFieldException"); e.printStackTrace(); } if (mCursorDrawableField != null) { mCursorDrawableField.setAccessible(true); try { mCursorDrawableField.set(editText, 0); } catch (IllegalArgumentException e) { Log.i(TAG, "IllegalArgumentException"); e.printStackTrace(); } catch (NotFoundException e) { Log.i(TAG, "NotFoundException"); e.printStackTrace(); } catch (IllegalAccessException e) { Log.i(TAG, "IllegalAccessException"); e.printStackTrace(); } } } } 
0
source

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


All Articles