-1

I am trying to implement RecyclerView, but it does not get imported in main activity.

Here is my code:

package com.example.recycler_view;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    RecyclerView rv = (RecyclerView)findViewById(R.id.rv);
    }

}

Please any one tell how I am going to import the RecyclerView.

Nickolaus
  • 4,785
  • 4
  • 38
  • 60
Nikhil Singh
  • 300
  • 2
  • 13
  • 1
    did you write below code in gradle compile 'com.android.support:recyclerview-v7:23.1.1' – Madhur Dec 01 '15 at 07:13
  • @Madhur he is right. You need to add the following lines in dependicies block in your build.gradle belongs to your executor module which can be named as "app". Also dont forget to call rv.setLayoutManager(...). Otherwise your recycler view dosent work. :) – Emre Aktürk Dec 01 '15 at 07:15
  • Which IDE Eclipse or Android Studio? – Suhas Bachewar Dec 01 '15 at 07:23
  • How i am going to get gradle file i am using eclipse , is gradle file concept is also in while devloping in eclipse – Nikhil Singh Dec 04 '15 at 08:40
  • check this tutorial post : http://wiki.workassis.com/android-recyclerview-example/ – Bikesh M Aug 31 '16 at 08:02
  • Refer These links [RecyclerView ](http://developer.android.com/training/material/lists-cards.html) [RecyclerView ](http://www.exoguru.com/android/ui/cardview/custom-android-list.html) – Pavan Bilagi Dec 01 '15 at 07:21

1 Answers1

0

You'll have to add the following gradle dependency

compile 'com.android.support:recyclerview-v7:+'
Ahmad Alkhatib
  • 1,230
  • 2
  • 14
  • 31