ClassCastException: android.support.v7.widget -


i try use action bar , got execption

   08-08 00:54:08.913: e/androidruntime(18468): fatal exception: main 08-08 00:54:08.913: e/androidruntime(18468): java.lang.classcastexception: android.support.v7.widget.shareactionprovider cannot cast android.view.actionprovider 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.menuinflater$menustate.readitem(menuinflater.java:374) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.menuinflater.parsemenu(menuinflater.java:160) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.menuinflater.inflate(menuinflater.java:110) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.example.workoutlog.addworkoutpage.oncreateoptionsmenu(addworkoutpage.java:3190) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.app.activity.oncreatepanelmenu(activity.java:2490) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.android.internal.policy.impl.phonewindow.preparepanel(phonewindow.java:460) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.android.internal.policy.impl.phonewindow.doinvalidatepanelmenu(phonewindow.java:822) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.android.internal.policy.impl.phonewindow$1.run(phonewindow.java:253) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.choreographer$callbackrecord.run(choreographer.java:749) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.choreographer.docallbacks(choreographer.java:562) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.choreographer.doframe(choreographer.java:531) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:735) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.os.handler.handlecallback(handler.java:725) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.os.handler.dispatchmessage(handler.java:92) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.os.looper.loop(looper.java:137) 08-08 00:54:08.913: e/androidruntime(18468):    @ android.app.activitythread.main(activitythread.java:5226) 08-08 00:54:08.913: e/androidruntime(18468):    @ java.lang.reflect.method.invokenative(native method) 08-08 00:54:08.913: e/androidruntime(18468):    @ java.lang.reflect.method.invoke(method.java:511) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:795) 08-08 00:54:08.913: e/androidruntime(18468):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:562) 08-08 00:54:08.913: e/androidruntime(18468):    @ dalvik.system.nativestart.main(native method) 

i have read error , java paths.

i tried kinds of solutins still got error.

here java path order , export:

enter image description here

my codes:

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" >  <item android:id="@+id/save_wotkout_ab"     android:title="add item"     android:icon="@android:drawable/ic_menu_save"     android:showasaction="ifroom"/>   <item android:id="@+id/delete_workout_ab"     android:title="add item"     android:icon="@android:drawable/ic_delete"     android:showasaction="ifroom"/>   <item android:id="@+id/search_ab"     android:title="add item"     android:icon="@android:drawable/ic_menu_search"     android:actionviewclass="android.support.v7.widget.searchview"     android:showasaction="ifroom|collapseactionview"/>       <item     android:id="@+id/action_share"     android:actionproviderclass="android.support.v7.widget.shareactionprovider"     android:showasaction="ifroom"     android:title="share"/>  </menu> 

where exception is:

 @override         public boolean oncreateoptionsmenu(menu menu) {             // inflate menu items use in action bar             menuinflater inflater = getmenuinflater();             inflater.inflate(r.menu.add_workout_actionbar, menu);              menuitem shareitem = menu.finditem(r.id.action_share);             mshareactionprovider = (shareactionprovider)                     menuitemcompat.getactionprovider(shareitem);             mshareactionprovider.setshareintent(getdefaultintent());              return super.oncreateoptionsmenu(menu);         } 

thank helping

android design adding action provider


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -