appcompat - DrawerLayout, NavigationView, and android:Theme.Material.Light not compatible? -


i'm trying experiment, first time not using appcompatactivity , using new material themes. have no need or desire backwards compatibility in particular app, building marshmallow.

the intent initial activity have actionbar navigation menu on left works fine in appcompat. however, after setting basic theme stuff no longer use appcompat themes, changing layouts, , trying crank main activity, indexoutofboundsexception occurs after activity's oncreate() method finished. exception happens during intialization of internal class android.support.design.internal.navigationmenuitemview.

the same exception happens whether navigationview , related menu defined in xml, or added programmatically. i'm pretty sure whatever wrong related new material theme , not using appcompat stuff.

has else run this? should work, or being dumb?

here snippets: app style customizations removed:

    <style name="apptheme" parent="android:theme.material.light">         <item name="colorprimary">@color/colorprimary</item>         <item name="colorprimarydark">@color/colorprimarydark</item>         <item name="coloraccent">@color/coloraccent</item>     </style> 

activity_main layout file:

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitssystemwindows="true">      <include layout="@layout/app_bar_main"         android:layout_width="match_parent"         android:layout_height="match_parent" />      <!-- comment nav view out , activity starts fine, no menu of course -->     <android.support.design.widget.navigationview         android:id="@+id/nav_view"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="start"         android:fitssystemwindows="true"         app:menu="@menu/activity_main_drawer" />  </android.support.v4.widget.drawerlayout> 

sample main activity code:

public class mainactivity extends activity     implements navigationview.onnavigationitemselectedlistener {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     actionbardrawertoggle toggle = new actionbardrawertoggle(             this, drawer, r.string.navigation_drawer_open, r.string.navigation_drawer_close);     toggle.syncstate();      /* uncomment if xml has view def removed, same exception results either way     navigationview navigationview = new navigationview(this);     navigationview.setnavigationitemselectedlistener(this);     navigationview.setlayoutparams(new drawerlayout.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content, gravity.start));     navigationview.setfitssystemwindows(true);     navigationview.inflatemenu(r.menu.activity_main_drawer);     drawer.addview(navigationview);     */ } ... 

i debugged view.java code , related typedarray code , can see failing trying process attributes while building internal menu item class. smells bug, first time i've tried not using appcompat themes , appcompatactivity. i've tried using noactionbar variant of theme , adding own toolbar, makes no difference, same error.

any ideas/thoughts? in advance. lemme know if i've omitted useful info, i'm newbie

finally, here giant call stack. root cause third exception in stack:

06-10 14:49:53.763 30675-30675/test e/cause: binary xml file line #17: error inflating class android.support.design.internal.navigationmenuitemview android.view.inflateexception: binary xml file line #17: error inflating class android.support.design.internal.navigationmenuitemview     @ android.view.layoutinflater.createview(layoutinflater.java:645)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:764)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)     @ android.view.layoutinflater.inflate(layoutinflater.java:492)     @ android.view.layoutinflater.inflate(layoutinflater.java:423)     @ android.support.design.internal.navigationmenupresenter$normalviewholder.<init>(navigationmenupresenter.java:278)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:379)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:328)     @ android.support.v7.widget.recyclerview$adapter.createviewholder(recyclerview.java:5482)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4707)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4617)     @ android.support.v7.widget.linearlayoutmanager$layoutstate.next(linearlayoutmanager.java:1994)     @ android.support.v7.widget.linearlayoutmanager.layoutchunk(linearlayoutmanager.java:1390)     @ android.support.v7.widget.linearlayoutmanager.fill(linearlayoutmanager.java:1353)     @ android.support.v7.widget.linearlayoutmanager.onlayoutchildren(linearlayoutmanager.java:574)     @ android.support.v7.widget.recyclerview.dispatchlayoutstep2(recyclerview.java:3028)     @ android.support.v7.widget.recyclerview.onmeasure(recyclerview.java:2625)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.support.design.widget.navigationview.onmeasure(navigationview.java:223)     @ android.view.view.measure(view.java:18794)     @ android.support.v4.widget.drawerlayout.onmeasure(drawerlayout.java:1104)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ com.android.internal.widget.actionbaroverlaylayout.onmeasure(actionbaroverlaylayout.java:446)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ com.android.internal.policy.phonewindow$decorview.onmeasure(phonewindow.java:2643)     @ android.view.view.measure(view.java:18794)     @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:2100)     @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1216)     @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1452)     @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1107)     @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:6013)     @ android.view.choreographer$callbackrecord.run(choreographer.java:858)     @ android.view.choreographer.docallbacks(choreographer.java:670)     @ android.view.choreographer.doframe(choreographer.java:606)     @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:844)     @ android.os.handler.handlecallback(handler.java:739)     @ android.os.handler.dispatchmessage(handler.java:95)     @ android.os.looper.loop(looper.java:148)     @ android.app.activitythread.main(activitythread.java:5417)     @ java.lang.reflect.method.invoke(native method)     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 06-10 14:49:55.023 30675-30675/test e/cause: null java.lang.reflect.invocationtargetexception     @ java.lang.reflect.constructor.newinstance(native method)     @ android.view.layoutinflater.createview(layoutinflater.java:619)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:764)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)     @ android.view.layoutinflater.inflate(layoutinflater.java:492)     @ android.view.layoutinflater.inflate(layoutinflater.java:423)     @ android.support.design.internal.navigationmenupresenter$normalviewholder.<init>(navigationmenupresenter.java:278)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:379)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:328)     @ android.support.v7.widget.recyclerview$adapter.createviewholder(recyclerview.java:5482)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4707)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4617)     @ android.support.v7.widget.linearlayoutmanager$layoutstate.next(linearlayoutmanager.java:1994)     @ android.support.v7.widget.linearlayoutmanager.layoutchunk(linearlayoutmanager.java:1390)     @ android.support.v7.widget.linearlayoutmanager.fill(linearlayoutmanager.java:1353)     @ android.support.v7.widget.linearlayoutmanager.onlayoutchildren(linearlayoutmanager.java:574)     @ android.support.v7.widget.recyclerview.dispatchlayoutstep2(recyclerview.java:3028)     @ android.support.v7.widget.recyclerview.onmeasure(recyclerview.java:2625)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.support.design.widget.navigationview.onmeasure(navigationview.java:223)     @ android.view.view.measure(view.java:18794)     @ android.support.v4.widget.drawerlayout.onmeasure(drawerlayout.java:1104)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ com.android.internal.widget.actionbaroverlaylayout.onmeasure(actionbaroverlaylayout.java:446)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ com.android.internal.policy.phonewindow$decorview.onmeasure(phonewindow.java:2643)     @ android.view.view.measure(view.java:18794)     @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:2100)     @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1216)     @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1452)     @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1107)     @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:6013)     @ android.view.choreographer$callbackrecord.run(choreographer.java:858)     @ android.view.choreographer.docallbacks(choreographer.java:670)     @ android.view.choreographer.doframe(choreographer.java:606)     @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:844)     @ android.os.handler.handlecallback(handler.java:739)     @ android.os.handler.dispatchmessage(handler.java:95)     @ android.os.looper.loop(looper.java:148)     @ android.app.activitythread.main(activitythread.java:5417)     @ java.lang.reflect.method.invoke(native method)     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 06-10 14:49:56.083 30675-30675/test e/cause: length=522; index=540 java.lang.arrayindexoutofboundsexception: length=522; index=540     @ android.content.res.typedarray.getvalueat(typedarray.java:1132)     @ android.content.res.typedarray.getdimensionpixelsize(typedarray.java:661)     @ android.view.view.<init>(view.java:3964)     @ android.view.viewgroup.<init>(viewgroup.java:573)     @ android.view.viewgroup.<init>(viewgroup.java:569)     @ android.support.v7.widget.linearlayoutcompat.<init>(linearlayoutcompat.java:148)     @ android.support.design.internal.foregroundlinearlayout.<init>(foregroundlinearlayout.java:56)     @ android.support.design.internal.navigationmenuitemview.<init>(navigationmenuitemview.java:64)     @ android.support.design.internal.navigationmenuitemview.<init>(navigationmenuitemview.java:60)     @ java.lang.reflect.constructor.newinstance(native method)     @ android.view.layoutinflater.createview(layoutinflater.java:619)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:764)     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)     @ android.view.layoutinflater.inflate(layoutinflater.java:492)     @ android.view.layoutinflater.inflate(layoutinflater.java:423)     @ android.support.design.internal.navigationmenupresenter$normalviewholder.<init>(navigationmenupresenter.java:278)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:379)     @ android.support.design.internal.navigationmenupresenter$navigationmenuadapter.oncreateviewholder(navigationmenupresenter.java:328)     @ android.support.v7.widget.recyclerview$adapter.createviewholder(recyclerview.java:5482)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4707)     @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4617)     @ android.support.v7.widget.linearlayoutmanager$layoutstate.next(linearlayoutmanager.java:1994)     @ android.support.v7.widget.linearlayoutmanager.layoutchunk(linearlayoutmanager.java:1390)     @ android.support.v7.widget.linearlayoutmanager.fill(linearlayoutmanager.java:1353)     @ android.support.v7.widget.linearlayoutmanager.onlayoutchildren(linearlayoutmanager.java:574)     @ android.support.v7.widget.recyclerview.dispatchlayoutstep2(recyclerview.java:3028)     @ android.support.v7.widget.recyclerview.onmeasure(recyclerview.java:2625)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.support.design.widget.navigationview.onmeasure(navigationview.java:223)     @ android.view.view.measure(view.java:18794)     @ android.support.v4.widget.drawerlayout.onmeasure(drawerlayout.java:1104)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ com.android.internal.widget.actionbaroverlaylayout.onmeasure(actionbaroverlaylayout.java:446)     @ android.view.view.measure(view.java:18794)     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5951)     @ android.widget.framelayout.onmeasure(framelayout.java:194)     @ com.android.internal.policy.phonewindow$decorview.onmeasure(phonewindow.java:2643)     @ android.view.view.measure(view.java:18794)     @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:2100)     @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1216)     @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1452)     @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1107)     @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:6013)     @ android.view.choreographer$callbackrecord.run(choreographer.java:858)     @ android.view.choreographer.docallbacks(choreographer.java:670)     @ android.view.choreographer.doframe(choreographer.java:606) 

most of design support library, including navigationview, requires use of appcompat. you'll need switch using appcompatactivity , appcompat theme if want use design library components.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -