Created
October 12, 2010 23:24
-
-
Save Redth/623116 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Android.App; | |
| using Android.Content; | |
| using Android.Runtime; | |
| using Android.Views; | |
| using Android.Widget; | |
| using Android.OS; | |
| namespace MonoDroid.CustomList | |
| { | |
| [Activity(Label = "1 CustomList", MainLauncher = true)] | |
| public class CustomList : Activity | |
| { | |
| CustomListAdapter listAdapter; | |
| public CustomList(IntPtr handle) | |
| : base(handle) | |
| { | |
| } | |
| protected override void OnCreate(Bundle bundle) | |
| { | |
| base.OnCreate(bundle); | |
| //Set the Activity's view to our list layout | |
| SetContentView(Resource.layout.customlist); | |
| //Create our adapter | |
| listAdapter = new CustomListAdapter(this); | |
| //Find the listview reference | |
| var listView = FindViewById<ListView>(Resource.id.listView); | |
| //Hook up our adapter to our ListView | |
| listView.Adapter = listAdapter; | |
| //Wire up the click event | |
| listView.ItemClick += new EventHandler<ItemEventArgs>(listView_ItemClick); | |
| } | |
| void listView_ItemClick(object sender, ItemEventArgs e) | |
| { | |
| //Get our item from the list adapter | |
| var item = this.listAdapter.GetItemAtPosition(e.Position); | |
| //Make a toast with the item name just to show it was clicked | |
| Toast.MakeText(this, item.Name + " Clicked!", ToastLength.Short).Show(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment