public override View GetView(int position, View convertView, ViewGroup parent) { var view = convertView ?? _activity.LayoutInflater.Inflate( Resource.Layout.ContactListItem, parent, false); var txtContactName = view.FindViewById <TextView> (Resource.Id.txtContactName); var txtPhoneNumber = view.FindViewById <TextView> (Resource.Id.txtPhoneNumber); var imgContactThumb = view.FindViewById <ImageView> (Resource.Id.imgContactThumb); txtPhoneNumber.Text = _contactList [position].Number; // For each number but the first one if (position > 0) { // We are on the first contact's number if (_contactList [position - 1].Id != _contactList [position].Id) { // Set contact name txtContactName.Text = _contactList [position].DisplayName; // Handle contact's image if (_contactList [position].PhotoThumbnailId == null) { imgContactThumb = view.FindViewById <ImageView> (Resource.Id.imgContactThumb); // TODO: corriger ca Bitmap contactImageBmp = BitmapFactory.DecodeResource(parent.Context.Resources, 1); if (contactImageBmp == null) { Bitmap.Config conf = Bitmap.Config.Argb8888; // see other conf types Bitmap bmp = Bitmap.CreateBitmap(200, 200, conf); bmp.EraseColor(Android.Graphics.Color.ParseColor("#0099CC")); Drawable circleContactImage = new CircleDrawable(bmp); imgContactThumb.SetImageDrawable(circleContactImage); } } else { imgContactThumb.SetImageURI(_contactList[position].GetThumbnailUri()); } } // We are on additional contact's number else { // Remove image imgContactThumb.SetImageDrawable(null); // Empty contact name txtContactName.Text = null; } } view.SetTag(Resource.String.NormalizedPhone, _contactList [position].DisplayName); return(view); }
public override View GetView(int position, View convertView, ViewGroup parent) { var view = convertView ?? _activity.LayoutInflater.Inflate ( Resource.Layout.ContactListItem, parent, false); var txtContactName = view.FindViewById<TextView> (Resource.Id.txtContactName); var txtPhoneNumber = view.FindViewById<TextView> (Resource.Id.txtPhoneNumber); var imgContactThumb = view.FindViewById<ImageView> (Resource.Id.imgContactThumb); txtPhoneNumber.Text = _contactList [position].Number; // For each number but the first one if (position > 0) { // We are on the first contact's number if (_contactList [position - 1].Id != _contactList [position].Id) { // Set contact name txtContactName.Text = _contactList [position].DisplayName; // Handle contact's image if (_contactList [position].PhotoThumbnailId == null) { imgContactThumb = view.FindViewById<ImageView> (Resource.Id.imgContactThumb); // TODO: corriger ca Bitmap contactImageBmp = BitmapFactory.DecodeResource (parent.Context.Resources, 1); if (contactImageBmp == null) { Bitmap.Config conf = Bitmap.Config.Argb8888; // see other conf types Bitmap bmp = Bitmap.CreateBitmap (200, 200, conf); bmp.EraseColor (Android.Graphics.Color.ParseColor ("#0099CC")); Drawable circleContactImage = new CircleDrawable (bmp); imgContactThumb.SetImageDrawable (circleContactImage); } } else { imgContactThumb.SetImageURI ( _contactList[position].GetThumbnailUri()); } } // We are on additional contact's number else { // Remove image imgContactThumb.SetImageDrawable(null); // Empty contact name txtContactName.Text = null; } } view.SetTag (Resource.String.NormalizedPhone, _contactList [position].DisplayName); return view; }