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.
XMLCode
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:orientation="vertical"
-
- android:layout_width="fill_parent"
-
- android:layout_height="fill_parent"
-
- android:minWidth="25px"
-
- android:minHeight="25px">
- <ListView
-
- android:minWidth="25px"
-
- android:minHeight="25px"
-
- android:layout_width="match_parent"
-
- android:layout_height="match_parent"
-
- android:id="@+id/listView1" />
- </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.