Created
May 6, 2016 09:44
-
-
Save Krumelur/295b234beb49bf771a0387711860988a to your computer and use it in GitHub Desktop.
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
public override View GetView (int position, View convertView, ViewGroup parent) | |
{ | |
var inflater = LayoutInflater.From (parent.Context); | |
var view = convertView; | |
if(view == null) | |
{ | |
view = inflater.Inflate (Resource.Layout.InstructorRow, parent, false); | |
} | |
var photo = view.FindViewById<ImageView> (Resource.Id.photoImageView); | |
var name = view.FindViewById<TextView > (Resource.Id.nameTextView); | |
var specialty = view.FindViewById<TextView > (Resource.Id.specialtyTextView); | |
using(Stream stream = parent.Context.Assets.Open (instructors [position].ImageUrl)) | |
{ | |
((BitmapDrawable)photo.Drawable)?.Bitmap?.Recycle(); | |
// Kind of heavy, but it prevents OOM. | |
GC.Collect(); | |
Drawable drawable = Drawable.CreateFromStream (stream, null); | |
photo.SetImageDrawable (drawable); | |
} | |
name.Text = instructors [position].Name; | |
specialty.Text = instructors [position].Specialty; | |
return view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment