代码中这样写:
try {
java.lang.reflect.Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
f.setAccessible(true);
f.set(valueView, R.drawable.edittext_cursor);
} catch (Exception e) {
}
其中的valueView就是你用到的editText。
drawable中的edittext_cursor.xml文件如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#444444" />
<size android:width="1dp" />
</shape>
只要将你上面的#444444改成你想要的颜色就可以了。