xml - Android - FATAL EXCEPTION: Error inflating class abLayout - Custom Style Does Not Resolve -


i'm getting fatal error stating: binary xml file line #9: binary xml file line #9: error inflating class

all research i've done points creating custom style resolve issue:

got error inflating class android.support.design.widget.tablayout error inflating class android.support.design.widget.tablayout

or perhaps supportlibrary - or adding missing background:

android.view.inflateexception binary xml file line #1 error inflating class android.widget.relativelayout

however none of solutions seem resolve force close issue , i'm not sure how can resolved.

any suggestions appreciated.

chatfrag.java

public class chatfrag extends fragment {   ...     public chatviewpageradapter adapter;     private viewpager viewpager;     private tablayout alltabs; ...      @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {          super.oncreate(savedinstancestate);         context = getactivity().getapplicationcontext();         pref = getactivity().getsharedpreferences("myprefs", context.mode_private);         setup = setup.getinstance();         isloaded = false;         messagesfrag = this;           view main = inflater.inflate(r.layout.activity_chat, container, false);        ...         getallwidgets();         setupviewpager();          ...             private void setupviewpager() {         adapter = new chatviewpageradapter(getactivity().getsupportfragmentmanager());         activechats = new activechats();         visitors = new visitors();         adapter.addfragment(activechats, "active chats");         adapter.addfragment(visitors, "visitors");         setviewpageadapter();     }         private void getallwidgets() {         viewpager = (viewpager) getactivity().findviewbyid(r.id.viewpager);         viewpager.setoffscreenpagelimit(1);         alltabs = (tablayout) getactivity().findviewbyid(r.id.tabs);     }          private void setviewpageadapter() {         viewpager.setadapter(adapter);         alltabs.setontabselectedlistener(new tablayout.ontabselectedlistener() {             @override             public void ontabselected(tablayout.tab tab) {                 if (tab.getposition() != viewpager.getcurrentitem()) {                     viewpager.setcurrentitem(tab.getposition());                 }             }              @override             public void ontabunselected(tablayout.tab tab) {              }              @override             public void ontabreselected(tablayout.tab tab) {                 if (tab.getposition() == viewpager.getcurrentitem()) {                     adapter.notifydatasetchanged();                 }              }         });     } 

activity_chat.xml

<linearlayout 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:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     >      <android.support.design.widget.tablayout         android:id="@+id/tabs"         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:tabgravity="fill"         app:tabmode="fixed"         style="@style/mycustomtablayout"/>      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </linearlayout> 

logcat

                                                                                         --------- beginning of crash 09-21 11:08:15.434 25875-25875/com.redacted.redactedmobile e/androidruntime: fatal exception: main                                                                                          process: com.redacted.redactedmobile, pid: 25875                                                                                          android.view.inflateexception: binary xml file line #9: binary xml file line #9: error inflating class android.support.design.widget.tablayout                                                                                              @ android.view.layoutinflater.inflate(layoutinflater.java:539)                                                                                              @ android.view.layoutinflater.inflate(layoutinflater.java:423)                                                                                              @ com.redacted.redactedmobile.chatfrag.oncreateview(chatfrag.java:84) 

build.gradle

dependencies {   ...      compile 'com.android.support:appcompat-v7:23.4.0'     compile 'com.android.support:multidex:1.0.1'     compile 'com.android.support:design:23+' ...   } 

v21 styles.xml

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="apptheme" parent="theme.appcompat.light.darkactionbar">         <!-- customize theme here. -->         <item name="android:colorprimarydark">#227900</item>         <item name="android:colorprimary">#227900</item>         <item name="colorprimarydark">#227900</item>         <item name="colorprimary">#227900</item>         <item name="android:windowdisablepreview">true</item>     </style>     <style name="apptheme.base" parent="android:theme.material">         <item name="android:colorprimary">#3f51b5</item>         <item name="android:colorprimarydark">#303f9f</item>           <item name="android:coloraccent">#ff4081</item>     </style>     <style name="mycustomtablayout" parent="widget.design.tablayout">         <item name="tabindicatorcolor">#ff4081</item>     </style> </resources> 

you can delete style try instead of styling changing tab indicator color:

<android.support.design.widget.tablayout         android:id="@+id/tabs"         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:tabgravity="fill"         app:tabmode="fixed"         app:tabindicatorcolor="@color/your-color-name"/> 

and set color in colors...


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -