问题描述
- android中的edittext获得光标就报这样的错误,求大神指点怎么解决啊 5C
- 04-29 00:37:49.491 2548-2548/jt.com.shoppingcar W/Resources: Drawable android:drawable/text_cursor_material has unresolved theme attributes! Consider using Resources.getDrawable(int Theme) or Context.getDrawable(int).
java.lang.RuntimeException
at android.content.res.Resources.getDrawable(Resources.java:786)
at android.widget.Editor$InsertionHandleView.getHotspotX(Editor.java:3921)
at android.widget.Editor$HandleView.updateDrawable(Editor.java:3535)
at android.widget.Editor$HandleView.(Editor.java:3526)
at android.widget.Editor$InsertionHandleView.(Editor.java:3877)
at android.widget.Editor$InsertionPointCursorController.getHandle(Editor.java:4185)
at android.widget.Editor$InsertionPointCursorController.access$300(Editor.java:4149)
at android.widget.Editor.onTouchUpEvent(Editor.java:1814)
at android.widget.TextView.onTouchEvent(TextView.java:8373)
at android.view.View.dispatchTouchEvent(View.java:9306)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2255)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent(Activity.java:2820)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9526)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4255)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4121)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3715)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3807)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3864)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3715)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3681)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3689)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3662)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5947)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5921)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5882)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6050)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5432)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)下面我我的XML文件:
android:layout_width=""260dp""
android:layout_height=""40dp""
android:hint=""请输入你的用户名""
android:singleLine=""true""
android:selectAllOnFocus=""true""
android:background=""@drawable/bg_edit"" />
bg_edit.xml
<?xml version=""1.0"" encoding=""utf-8""?>bg_normal.xml
<?xml version=""1.0"" encoding=""utf-8""?>bg_focused.xml
<?xml version=""1.0"" encoding=""utf-8""?>android:width=""1dip""
android:color=""#728ea3"" />
解决方案
jt.com.shoppingcar W/Resources: Drawable android:drawable/text_cursor_material has unresolved theme attributes! Consider using Resources.getDrawable(int Theme) or Context.getDrawable(int).
java.lang.RuntimeException
这句话的意思是你不能在xml里面调用@drawable,可以放到代码里面去掉用,尝试一下Resources.getDrawable(int Theme) or Context.getDrawable(int).这俩个api看看是否可以调用成功!
解决方案二:
把@drawable改为@background即可
解决方案三:
没看出来你这个text_cursor_material引用在哪,自定义的文件吗,描述不是很清晰啊
解决方案四:
你的Log没有拷贝完整,不能定位到是哪里问题,大概是你用了一个有分歧的属性 android 不能处理;
楼主需要再多拷贝一些log定位问题;