50 likes | 76 Views
Xamarin is a Mobile Application Development and cross platform Development software. Greens providing free interview preparations with affordable fees.Greens Technology,the best institute for Xamarin Course in Chennai with flexible Timings.
E N D
In this is blog I will show you how to make ListView in Xamarin Android. Step -1 Open your Android solution in Xamarin Studio. Step -2 Update your main.axml file inside your Resoursce/ Layout folder <?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=”match_parent“> <ListViewandroid:id=”@+id/mainlistview” android:layout_height=”match_parent” android:layout_width=”match_parent“> </ListView> </LinearLayout>
Step -3 public class MainActivity: Activity { string[] items; ListViewmainList; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); items = new string[] { “Xamarin”, “Android”, “IOS”, “Windows”, “Xamarin-Native”, “Xamarin-Forms” };
// Set our view from the “main” layout resource SetContentView(Resource.Layout.Main); mainList = (ListView) FindViewById < ListView > (Resource.Id.mainlistview); mainList.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, items); } } Step -4 1. mainList.ItemClick += (s, e) => { 2. var t = items[e.Position]; 3. Android.Widget.Toast.MakeText(this, t, Android.Widget.ToastLength.Long).Show(); 4. };
GREENS TECHNOLOGYS Xamarin is a Mobile Application Development and cross platform Development software. Greens providing free interview preparations with affordable fees. Greens Technology,the best institute for Xamarin Course in Chennai with flexible Timings.