您可以尝试下面的代码片段。
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();
}
}
}
}
更新:我现在已经尝试过姜饼应用程序,它在那里也正常工作。该问题仅限于所有蜂窝版本为3.2。 – Vic 2011-07-21 18:29:34
您是否将输入类型设置为0(TYPE_NULL)?如果是这样,我确实有一个解决方法可以帮助你。 – 2012-03-22 19:51:49