当前位置:   article > 正文

关于EditText或WebView文字长按,actionMode出错问题解决方案_startactionmode 无效

startactionmode 无效
02-06 10:47:46.186: D/AndroidRuntime(2518): Shutting down VM</span>
  1. 02-06 10:47:46.186: W/dalvikvm(2518): threadid=1: thread exiting with uncaught exception (group=0x41837c08)
  2. 02-06 10:47:46.201: E/AndroidRuntime(2518): FATAL EXCEPTION: main
  3. 02-06 10:47:46.201: E/AndroidRuntime(2518): Process: com.taiyiheng.interestlibrary, PID: 2518
  4. 02-06 10:47:46.201: E/AndroidRuntime(2518): android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.widget.TintImageView
  5. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
  6. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
  7. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
  8. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
  9. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.internal.widget.ActionBarContextView.initForMode(ActionBarContextView.java:212)
  10. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.app.ActionBarActivityDelegateBase.startSupportActionModeFromWindow(ActionBarActivityDelegateBase.java:650)
  11. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.app.ActionBarActivityDelegate$1.startActionMode(ActionBarActivityDelegate.java:99)
  12. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.widget.WindowCallbackWrapper.startActionMode(WindowCallbackWrapper.java:69)
  13. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.internal.app.ToolbarActionBar.startActionMode(ToolbarActionBar.java:206)
  14. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.app.ActionBarActivityDelegateBase.startSupportActionMode(ActionBarActivityDelegateBase.java:581)
  15. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.app.ActionBarActivityDelegateHC.startActionModeForChild(ActionBarActivityDelegateHC.java:62)
  16. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.internal.widget.NativeActionModeAwareLayout.startActionModeForChild(NativeActionModeAwareLayout.java:44)
  17. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
  18. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
  19. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
  20. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.View.startActionMode(View.java:4728)
  21. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.widget.Editor.startSelectionActionMode(Editor.java:1804)
  22. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.widget.Editor.performLongClick(Editor.java:1035)
  23. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.widget.TextView.performLongClick(TextView.java:9981)
  24. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.View$CheckForLongPress.run(View.java:19303)
  25. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.os.Handler.handleCallback(Handler.java:733)
  26. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.os.Handler.dispatchMessage(Handler.java:95)
  27. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.os.Looper.loop(Looper.java:157)
  28. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.app.ActivityThread.main(ActivityThread.java:5387)
  29. 02-06 10:47:46.201: E/AndroidRuntime(2518): at java.lang.reflect.Method.invokeNative(Native Method)
  30. 02-06 10:47:46.201: E/AndroidRuntime(2518): at java.lang.reflect.Method.invoke(Method.java:515)
  31. 02-06 10:47:46.201: E/AndroidRuntime(2518): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  32. 02-06 10:47:46.201: E/AndroidRuntime(2518): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  33. 02-06 10:47:46.201: E/AndroidRuntime(2518): at dalvik.system.NativeStart.main(Native Method)
  34. 02-06 10:47:46.201: E/AndroidRuntime(2518): Caused by: java.lang.reflect.InvocationTargetException
  35. 02-06 10:47:46.201: E/AndroidRuntime(2518): at java.lang.reflect.Constructor.constructNative(Native Method)
  36. 02-06 10:47:46.201: E/AndroidRuntime(2518): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  37. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
  38. 02-06 10:47:46.201: E/AndroidRuntime(2518): ... 28 more
  39. 02-06 10:47:46.201: E/AndroidRuntime(2518): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010028 a=-1}
  40. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.content.res.Resources.loadDrawable(Resources.java:3014)
  41. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
  42. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.widget.ImageView.<init>(ImageView.java:133)
  43. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.internal.widget.TintImageView.<init>(TintImageView.java:47)
  44. 02-06 10:47:46.201: E/AndroidRuntime(2518): at android.support.v7.internal.widget.TintImageView.<init>(TintImageView.java:43)
  45. 02-06 10:47:46.201: E/AndroidRuntime(2518): ... 31 more


请注意上述错误中的startActionMode(error-log,12行),这是指出了此次错误发生的原因,一个ActionMode,再加上Resource is not a Drawable。

解决方案:请修改App里的Theme,在value的各个版本里,使其<style name="AppTheme" parent="Base.Theme.AppCompat.Light">中的parent直接引用Base.Theme.AppCompat.Light(或者引用包含下面代码中item值的样式),中间可以直接跳过引用Theme.AppCompat.Light等样式。

  1. <span style="font-size:14px;"> <style name="Base.Theme.AppCompat.Light" parent="Base.V14.Theme.AppCompat.Light">
  2. <item name="android:actionModeCutDrawable">?actionModeCutDrawable</item>
  3. <item name="android:actionModeCopyDrawable">?actionModeCopyDrawable</item>
  4. <item name="android:actionModePasteDrawable">?actionModePasteDrawable</item>
  5. <item name="android:actionModeSelectAllDrawable">?actionModeSelectAllDrawable</item>
  6. <item name="android:actionModeShareDrawable">?actionModeShareDrawable</item>
  7. </style></span>
在有的Theme中可能因为其他原因不能直接找到Base.V7.Theme.AppCompat.Light,在Base.V7.Theme.AppCompat.Light里包含了系统ContextBarMenu的各种背景图片设置,所以就会报Resource文件找不到。

这可能是其中一种解决方法。

另外附上XML代码:value-14

  1. <resources>
  2. <!--Base application theme for API 14+. This theme completely replaces
  3. AppBaseTheme from BOTH res/values/styles.xml and
  4. res/values-v11/styles.xml on API 14+ devices. -->
  5. <style name="AppTheme" parent="Base.Theme.AppCompat.Light">
  6. <!-- API 14 theme customizations can go here. -->
  7. <item name="windowActionBar">false</item>
  8. <item name="android:windowNoTitle">true</item>
  9. </style>
  10. </resources>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/391042
推荐阅读
相关标签
  

闽ICP备14008679号