我正在尝试实现 ShareActionProvider 但得到:
02-20 04:14:28.894: E/AndroidRuntime(1145): Process: com.learn2crack.tab, PID: 1145
02-20 04:14:28.894: E/AndroidRuntime(1145): java.lang.ClassCastException: android.support.v7.widget.ShareActionProvider cannot be cast to android.view.ActionProvider
菜单.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: main
02-20 04:14:28.894: E/AndroidRuntime(1145): Process: com.learn2crack.tab, PID: 1145
02-20 04:14:28.894: E/AndroidRuntime(1145): java.lang.ClassCastException: android.support.v7.widget.ShareActionProvider cannot be cast to android.view.ActionProvider
02-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$1.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)