Zac Gross

Code & More

Xamarin Simple Text List View Helper

| Comments

Recently while working on an Xamarin based Android project I came up with a handy helper class for displaying basic list views. It saves alot of boilerplate code by not forcing a new adapter implementation for every domain object you want to use in a list view.

The code:

And to use it:

1
ListAdapter = new SimpleTextAdapter<SomeBusinessObject> (this,objects, (item) => { return item.Name;});

Use it with a custom id field:

1
ListAdapter = new SimpleTextAdapter<SomeBusinessObject> (this,objects, (item) => { return item.Name;}, (item) => { return item.CustomId;});

Comments