ClassCastException:android.support.v7.widget.ShareActionProvider

ClassCastException:android.support.v7.widget.ShareActionProvider,第1张

概述我正在尝试实现ShareActionProvider,但得到:02-2004:14:28.894:E/AndroidRuntime(1145):Process:com.learn2crack.tab,PID:114502-2004:14:28.894:E/AndroidRuntime(1145):java.lang.ClassCastException:android.support.v7.widget.ShareActionProvidercannotbecast

我正在尝试实现ShareActionProvIDer,但得到:

02-20 04:14:28.894: E/AndroIDRuntime(1145): Process: com.learn2crack.tab, PID: 114502-20 04:14:28.894: E/AndroIDRuntime(1145): java.lang.classCastException: androID.support.v7.Widget.ShareActionProvIDer cannot be cast to androID.vIEw.ActionProvIDer

menu.xml文件:

  <item    androID:ID="@+ID/share"    androID:title="@string/share"    androID:actionProvIDerClass="androID.support.v7.Widget.ShareActionProvIDer"    androID:showAsAction="always" />

我把它导入了我的班级:

    import androID.support.v7.Widget.ShareActionProvIDer;

完整日志:

02-20 04:14:28.894: E/AndroIDRuntime(1145): FATAL EXCEPTION: main02-20 04:14:28.894: E/AndroIDRuntime(1145): Process: com.learn2crack.tab, PID: 114502-20 04:14:28.894: E/AndroIDRuntime(1145): java.lang.classCastException: androID.support.v7.Widget.ShareActionProvIDer cannot be cast to androID.vIEw.ActionProvIDer02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.MenuInflater$MenuState.readItem(MenuInflater.java:374)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.MenuInflater.parseMenu(MenuInflater.java:160)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.MenuInflater.inflate(MenuInflater.java:110)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.learn2crack.tab.MainActivity.onCreateOptionsMenu(MainActivity.java:72)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.app.Activity.onCreatePanelMenu(Activity.java:2538)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.androID.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:436)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.androID.internal.policy.impl.PhoneWindow.doInvalIDatePanelMenu(PhoneWindow.java:800)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.androID.internal.policy.impl.PhoneWindow.run(PhoneWindow.java:221)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.Choreographer$CallbackRecord.run(Choreographer.java:761)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.Choreographer.doCallbacks(Choreographer.java:574)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.Choreographer.doFrame(Choreographer.java:543)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.vIEw.Choreographer$FramedisplayEventReceiver.run(Choreographer.java:747)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.os.Handler.handleCallback(Handler.java:733)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.os.Handler.dispatchMessage(Handler.java:95)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.os.Looper.loop(Looper.java:136)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at androID.app.ActivityThread.main(ActivityThread.java:5017)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at java.lang.reflect.Method.invokeNative(Native Method)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at java.lang.reflect.Method.invoke(Method.java:515)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:595)02-20 04:14:28.894: E/AndroIDRuntime(1145):     at dalvik.system.NativeStart.main(Native Method)

解决方法:

改成

<?xml version="1.0" enCoding="utf-8"?><menu xmlns:androID="http://schemas.androID.com/apk/res/androID"      xmlns:yourapp="http://schemas.androID.com/apk/res-auto" >     <item      androID:ID="@+ID/share"      androID:title="@string/share"      yourapp:actionProvIDerClass="androID.support.v7.Widget.ShareActionProvIDer"      yourapp:showAsAction="always" />    ...</menu>

检查主题使用ShareActionProvIDer

http://developer.android.com/guide/topics/ui/actionbar.html

总结

以上是内存溢出为你收集整理的ClassCastException:android.support.v7.widget.ShareActionProvider全部内容,希望文章能够帮你解决ClassCastException:android.support.v7.widget.ShareActionProvider所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1107232.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存