-4

I'm trying to create an app that displays a list of all user contacts, and im using RecyclerView. when i try to run my app it fails, i notice then the problem is in "activity_main.xml" in the lines:

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86
dafrimi
  • 11
  • 1

2 Answers2

0

The problem was in the xml file. need to replace

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

in this:

    <androidx.recyclerview.widget.RecyclerView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:id="@+id/recycler_view"/>
dafrimi
  • 11
  • 1
-1

Don't forget to set layout manager in your xml or programmatically in onCreate:

app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"

or

recyclerView.layoutManager = LinearLayoutManager(this)

Dmytro Batyuk
  • 957
  • 8
  • 15