Created
July 17, 2015 05:10
-
-
Save vkoppaka/933084220257e9bfb267 to your computer and use it in GitHub Desktop.
Main Activity Custom Adapater
This file contains 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 Android.App; | |
using Android.OS; | |
using Android.Widget; | |
namespace AdapterDemo2 | |
{ | |
[Activity(Label = "AdapterDemo2", | |
MainLauncher = true, | |
Theme = "@android:style/Theme.Holo.Light", | |
Icon = "@drawable/icon")] | |
public class MainActivity : Activity | |
{ | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
// Set our view from the "main" layout resource | |
SetContentView(Resource.Layout.Main); | |
var moviesListView = FindViewById<ListView>(Resource.Id.moviesListView); | |
moviesListView.FastScrollEnabled = true; | |
moviesListView.ItemClick += moviesListView_ItemClick; | |
var moviesAdapter = new MovieAdapter(this, MoviesRepository.Movies); | |
moviesListView.Adapter = moviesAdapter; | |
} | |
void moviesListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) | |
{ | |
Toast.MakeText(this, MoviesRepository.Movies[e.Position].ToString(), ToastLength.Long).Show(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment