android - Support Contextual Action Bar never inflates -


in order add contextual action bar application using support action bar v7 library implemented :

my actionbaractivity (support v7) :

    package com.supinfo.cubbyhole.mobileapp.activities;  import com.supinfo.cubbyhole.mobileapp.r;  import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.support.v7.view.actionmode; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview;  public class homy extends actionbaractivity {      private actionmode mactionmode;     private listview list;      @override     protected void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_home);          // instantiate , fill list custom adapter ... fine         list = (listview) findviewbyid(r.id.home_list);          string[] array = {"test", "test2", "test3"};         list.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, android.r.id.text1, array));          list.setonitemlongclicklistener(new adapterview.onitemlongclicklistener() {          @override          public boolean onitemlongclick(adapterview<?> adapterview, view view, int position, long l) {                   if (mactionmode != null) {                      return false;                  }                  mactionmode = startsupportactionmode(mactionmodecallback);                  view.setselected(true);                  return true;          }      });      }       private actionmode.callback mactionmodecallback = new actionmode.callback() {          @override         public boolean oncreateactionmode(actionmode mode, menu menu) {             // inflate menu resource providing context menu items             menuinflater inflater = mode.getmenuinflater();             inflater.inflate(r.menu.menu, menu);             return true;         }          // called each time action mode shown. called after oncreateactionmode,         // may called multiple times if mode invalidated.         @override         public boolean onprepareactionmode(actionmode mode, menu menu) {             return false; // return false if nothing done         }          // called when user selects contextual menu item         @override         public boolean onactionitemclicked(actionmode mode, menuitem item) {             switch (item.getitemid()) {                 case r.id.action_settings:                     mode.finish(); // action picked, close cab                     return true;                 default:                     return false;             }         }          // called when user exits action mode         @override         public void ondestroyactionmode(actionmode mode) {             mactionmode = null;         }      };  } 

my contextual_menu.xml :

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" >      <item         android:id="@+id/test"         android:icon="@android:drawable/ic_menu_delete"         android:showasaction="ifroom|withtext"         android:title="@string/test"         android:titlecondensed="delete">     </item>  </menu> 

and when try long click on item got stack error :

06-01 18:11:09.888: e/androidruntime(1206): fatal exception: main     06-01 18:11:09.888: e/androidruntime(1206): android.view.inflateexception: binary xml file line #17: error inflating class <unknown>     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.createview(layoutinflater.java:613)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.oncreateview(layoutinflater.java:660)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:685)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.inflate(layoutinflater.java:466)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.inflate(layoutinflater.java:396)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.widget.actionbarcontextview.initformode(actionbarcontextview.java:206)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.app.actionbarimpl.startactionmode(actionbarimpl.java:448)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.app.activity.onwindowstartingactionmode(activity.java:4881)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.support.v7.app.actionbaractivitydelegateics$windowcallbackwrapper.onwindowstartingactionmode(actionbaractivitydelegateics.java:341)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.policy.impl.phonewindow$decorview.startactionmode(phonewindow.java:2256)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.app.activity.startactionmode(activity.java:4864)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.support.v7.app.actionbaractivitydelegateics.startsupportactionmode(actionbaractivitydelegateics.java:185)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.support.v7.app.actionbaractivity.startsupportactionmode(actionbaractivity.java:194)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.supinfo.cubbyhole.mobileapp.activities.home$4.onitemlongclick(home.java:414)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.widget.abslistview.performlongpress(abslistview.java:2815)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.widget.abslistview$checkforlongpress.run(abslistview.java:2765)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.os.handler.handlecallback(handler.java:725)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.os.handler.dispatchmessage(handler.java:92)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.os.looper.loop(looper.java:137)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.app.activitythread.main(activitythread.java:5041)     06-01 18:11:09.888: e/androidruntime(1206):     @ java.lang.reflect.method.invokenative(native method)     06-01 18:11:09.888: e/androidruntime(1206):     @ java.lang.reflect.method.invoke(method.java:511)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)     06-01 18:11:09.888: e/androidruntime(1206):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560)     06-01 18:11:09.888: e/androidruntime(1206):     @ dalvik.system.nativestart.main(native method)     06-01 18:11:09.888: e/androidruntime(1206): caused by: java.lang.reflect.invocationtargetexception     06-01 18:11:09.888: e/androidruntime(1206):     @ java.lang.reflect.constructor.constructnative(native method)     06-01 18:11:09.888: e/androidruntime(1206):     @ java.lang.reflect.constructor.newinstance(constructor.java:417)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.view.layoutinflater.createview(layoutinflater.java:587)     06-01 18:11:09.888: e/androidruntime(1206):     ... 25 more     06-01 18:11:09.888: e/androidruntime(1206): caused by: java.lang.stackoverflowerror     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable$stateliststate.indexofstateset(statelistdrawable.java:295)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable$stateliststate.access$000(statelistdrawable.java:274)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.onstatechange(statelistdrawable.java:100)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.<init>(statelistdrawable.java:327)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.<init>(statelistdrawable.java:75)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:843)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxml(drawable.java:822)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.loaddrawable(resources.java:1950)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.getdrawable(resources.java:660)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.inflate(statelistdrawable.java:173)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:885)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxml(drawable.java:822)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.loaddrawable(resources.java:1950)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.getdrawable(resources.java:660)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.inflate(statelistdrawable.java:173)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:885)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxml(drawable.java:822)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.loaddrawable(resources.java:1950)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.content.res.resources.getdrawable(resources.java:660)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.statelistdrawable.inflate(statelistdrawable.java:173)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:885)     06-01 18:11:09.888: e/androidruntime(1206):     @ android.graphics.drawable 

i don't understand why contextual menu doesn't display...

-- edit --

issue due override of close icon in auto generated theme... had comment line :

<item name="android:actionmodeclosebuttonstyle">@style/actionbutton.closemode.cubbyhole</item> 

the exception stack overflow (how appropriate) while expanding "close" icon in cab. because of state-list drawable references itself.

the relevant code in actionbarcontextview.java is:

layoutinflater inflater = layoutinflater.from(mcontext); mclose = inflater.inflate(r.layout.action_mode_close_item, this, false); 

the problem might related incorrect definition of actionmodeclosedrawable drawable, or actionmodeclosebuttonstyle style.

is either 1 of them customized in theme, possibly recursive state-list drawable?

in case correctly defined, suggest cleaning , rebuilding project (the resource ids may incorrect).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -