一
File->project structure->Dependencies:
點擊All Dependencies處的加號,選擇Library Dependency:
在step1處輸入recyclerView,點擊search,搜索到以后,選中,點擊ok即可
二 在layout中加入
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/RecyclerViewId" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout>