Search code examples
androidandroid-layoutinflate-exceptionstaggered-gridview

Error inflating class com.origamilabs.library.views.StaggeredGridView


I m trying to use StaggeredGridView on my project with ActionBarSherlock.But i got this error when i try to inflate main_screen.xml to main.xml.

View view = inflater.inflate(R.layout.main_screen, container, false);

I have these log errors when launching my app:

Could not find class 'android.support.v4.util.SparseArrayCompat', referenced from method com.origamilabs.library.views.StaggeredGridView
 E/AndroidRuntime(18115): FATAL EXCEPTION: main
E/ndroidRuntime(18115): android.view.InflateException: Binary XML file line #8: Error inflating class com.origamilabs.library.views.StaggeredGridView
03-05 12:28:17.565: E/AndroidRuntime(18115):    at android.view.LayoutInflater.createView(LayoutInflater.java:626)
03-05 12:28:17.565: E/AndroidRuntime(18115):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
03-05 13:32:06.160: E/AndroidRuntime(22619):    at com.deu.sharepic.MainScreenActivity.onCreateView MainScreenActivity.java:84)

And my main_screen.xml ;

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:staggered="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

 <com.origamilabs.library.views.StaggeredGridView
android:id="@+id/chatList"
staggered:numColumns="2"
staggered:drawSelectorOnTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> 

</RelativeLayout>

And main.xml :

<android.support.v4.view.ViewPager
 xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
 android:layout_height="match_parent" />

Solution

  • I changed all andoid_support_v4.jar in that use all references projects with example project v4.jar. Than removed staggeredgridview.jar and add as library project.Than fixed.

    Thank u all.