I want to use CardView in my project, but when I run my application, I get the following error. I\'m using Eclipse
.
Error: Error inflating clas
I guess your problem is not within your xml layout, but your build.gradle settings.
When you want to use support library for Recyclerview or CardView in lower API devices, you not only needs to import the v7 library, but also needs to import Recycler View and Card View support independently.
Like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:support-v4:21.0.0'
}
This is noted by Google's documents here: https://developer.android.com/training/material/compatibility.html
See dependencies section.
Also, you can download google's sample of RecyclerView to digging out.
Hope this will help!