Let’s start,

Step 1

Open Visual Studio, New Project, Templates, Visual C#, Android, then Blank App (Android)

Select Blank App, then give Project Name and Project Location.

Step 2 - Next, Open Solution Explorer, Project Name, Resources, layout, then Main.axml. After that click Open Design View.



Step 3:
Go to Toolbar, select ListView, Drag and Drop in Design Page and then change id as android:id="@+id/listView1".



XMLCode

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:orientation="vertical"
  5. android:layout_width="fill_parent"
  6. android:layout_height="fill_parent"
  7. android:minWidth="25px"
  8. android:minHeight="25px">
  9. <ListView
  10. android:minWidth="25px"
  11. android:minHeight="25px"
  12. android:layout_width="match_parent"
  13. android:layout_height="match_parent"
  14. android:id="@+id/listView1" />
  15. </LinearLayout>

Step 4 - Next, Open Solution Explorer, Project Name, MainAtivity.cs and then click to open C# Code.



Here, first we add Namespace and then declare variables of ListView items. Go to OnCreate(), create the ListItem Values, then add in Adapter.

Create ListItemClick Event: listnames.ItemClick += Listnames_ItemClick;



Step 5 -
Press F5 or Build and Run the Application

Finally, we have successfully created a Xamarin Android ListView App.