Xamarin Android: Create Android Simple List View App

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.axmlAfter 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.   
  5. android:orientation="vertical"  
  6.   
  7. android:layout_width="fill_parent"  
  8.   
  9. android:layout_height="fill_parent"  
  10.   
  11. android:minWidth="25px"  
  12.   
  13. android:minHeight="25px">  
  14.     <ListView  
  15.   
  16. android:minWidth="25px"  
  17.   
  18. android:minHeight="25px"  
  19.   
  20. android:layout_width="match_parent"  
  21.   
  22. android:layout_height="match_parent"  
  23.   
  24. android:id="@+id/listView1" />  
  25. </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.

Up Next
    Ebook Download
    View all
    Learn
    View all