Introduction
In this article, I will explain about recycle view. For most Xamarin.Android applications you will want to display data of some sort. Android similarly allows the developer to populate UI controls with data, but there are differences in how you achieve this using Android. The purpose of this article is to show you how you can populate an Android UI control with data using Xamarin.Android and Visual Studio.
Step 1
Install the below Nuget Package from Nuget Manager.
Install-Package Xamarin.AndroidX.RecyclerView -Version 1.2.1
Step 2
Create the RecyclerView code in respective xml(activity_main.xml) files as mentioned below,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"/>
</RelativeLayout>
Step 3
Create the Item Content for RecyclerView code in respective XML(content_main.xml) files as mentioned below,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:layout_margin="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/customerName"
android:text="Manikandan"
android:fontFamily="serif"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/customerAddresss"
android:text="Thiruchy"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
Step 4
Create a model class(custromer.cs) properties as mentioned below,
public class Customer {
public string CustomerName {
get;
set;
}
public string CustomerAddress {
get;
set;
}
}
Step 5
Create a RecyclerView Adapter (CustomerAdapter) as mentioned below,


Join the conversation! Your thoughts help the community grow.