Populating row Views

Now that we have an instance of the view, we need to populate the fields. The View class defines a named FindViewById<T> method, which returns a typed instance of a widget contained in the view. You pass in the resource ID defined in the layout file to specify the control you wish to access.

The following code returns access to nameTextView and sets the Text property:

PointOfInterest poi = this [position];
view.FindViewById<TextView>(Resource.Id.nameTextView).Text = poi.Name;

Populating addrTextView is slightly more complicated because we only want to use the portions of the address we have, and we want to hide the TextView if none of the address components are present.

The View.Visibility property allows you to control the visibility ...

Get Xamarin Mobile Application Development for Android - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.