Use RecyclerView in Earlier Android Versions

I want to use RecyclerView in my android app. Below are the properties:

minSdkVersion="14" (ICS)
compile sdk version="21" (L)
Target sdk version="14" (ICS)

      

I added compile 'com.android.support:appcompat-v7:21.0.3'

under dependencies in build.gradle file. When I add the RecyclerView to XML I get the following error:

The following classes could not be found:
- android.support.v7.widget.RecyclerView (Fix Build Path, Create Class)

      

XML code:

<android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

      

I want the app to run on all devices above ICS. Please help me to solve this problem.

+3


source to share


3 answers


Add RecyclerView

v7 support library to build.gradle

. There are several v7 libraries, each dedicated to specific functionality.



compile 'com.android.support:recyclerview-v7:21.0.3'

+3


source


The RecyclerView is in its own library:



compile 'com.android.support:recyclerview-v7:21.0.3'

      

0


source


For targetSdkVersion 25/compileSdkVersion 25

and compilation 'com.android.support:appcompat-v7:25.3.1'

you need to use compile'com.android.support:recyclerview-v7:25.3.1'

The versions must be the same.

0


source







All Articles