private void CreateItemView(CountryWithFlag item, ComboBoxItemLoadingEventArgs e) { View originalItemView = e.ItemView; var itemView = LayoutInflater.FromContext(originalItemView.Context).Inflate(Resource.Layout.custom_item, (ViewGroup)originalItemView.Parent, false); TextView titleView = itemView.FindViewById <TextView>(Resource.Id.textView1); ImageView iconView = itemView.FindViewById <ImageView>(Resource.Id.imageView1); titleView.Text = item.Name; iconView.SetImageResource(item.ImageId); e.ItemView = itemView; }
private void CreateYouTubeItemView(YouTubeVideo video, ComboBoxItemLoadingEventArgs e) { View originalItemView = e.ItemView; var itemView = LayoutInflater.FromContext(originalItemView.Context).Inflate(Resource.Layout.ListItem, (ViewGroup)originalItemView.Parent, false); YoutubeViewHolder holder = new YoutubeViewHolder(itemView); holder.SetTitle(video.Title); holder.SetSubtitle(video.Description); holder.SetVideoThumbnail(video.Thumbnail, CancellationToken.None); e.ItemView = holder.ItemView; }
private UITableViewCell GetYoutubeCell(C1AutoComplete filterDropdown, YouTubeVideo video, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(YouTubeCellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, YouTubeCellIdentifier); } LoadImageInBackground(cell.ImageView, video.Thumbnail); cell.TextLabel.Text = video.Title; cell.DetailTextLabel.Text = video.Description; return(cell); }
private UITableViewCell GetCountryCell(C1AutoComplete custom, Countries item, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(CellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); } CGRect rect = cell.ContentView.Frame; UIView selectedBackgroundView = new UIView(cell.Bounds); selectedBackgroundView.BackgroundColor = new UIColor((nfloat)(0 / 255.0), (nfloat)(122.0 / 255.0), (nfloat)(255.0 / 255.0), (nfloat)1.0); cell.SelectedBackgroundView = selectedBackgroundView; foreach (UIView view in cell.ContentView.Subviews) { view.RemoveFromSuperview(); } UIImageView imageView = new UIImageView(new CGRect(4, 0, 48, 48)); NSString imagePath = new NSString("Images/" + (NSString)item.Name.ToLower() + ".png"); imageView.Image = new UIImage(imagePath); cell.ContentView.Add(imageView); UILabel label = new UILabel(new CGRect(65, 10, rect.Size.Width - 40, rect.Size.Height / 2)); label.Text = item.Name; cell.ContentView.Add(label); return(cell); }
private UITableViewCell GetCountryCell(C1AutoComplete custom, Countries item, ComboBoxItemLoadingEventArgs e) { UITableViewCell cell = e.GetReusableItemView(CellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); } CGRect rect = cell.ContentView.Frame; UIView selectedBackgroundView = new UIView(cell.Bounds); selectedBackgroundView.BackgroundColor = new UIColor((nfloat)(0 / 255.0), (nfloat)(122.0 / 255.0), (nfloat)(255.0 / 255.0), (nfloat)1.0); cell.SelectedBackgroundView = selectedBackgroundView; foreach (UIView view in cell.ContentView.Subviews) { view.RemoveFromSuperview(); } const int padding = 4; UIImageView imageView = new UIImageView(new CGRect(padding, 0, 48, 48)); UILabel label = new UILabel(new CGRect(65, 10, rect.Size.Width - 40, rect.Size.Height / 2)); imageView.TranslatesAutoresizingMaskIntoConstraints = false; label.TranslatesAutoresizingMaskIntoConstraints = false; NSString imagePath = new NSString("Images/" + (NSString)item.Name.ToLower() + ".png"); imageView.Image = new UIImage(imagePath); cell.ContentView.Add(imageView); label.Text = item.Name; cell.ContentView.Add(label); // anchor image to parent cell imageView.LeadingAnchor.ConstraintEqualTo(cell.LeadingAnchor, (nfloat)(padding)).Active = true; imageView.TopAnchor.ConstraintEqualTo(cell.TopAnchor).Active = true; imageView.BottomAnchor.ConstraintEqualTo(cell.BottomAnchor).Active = true; // anchor label follow to image label.LeadingAnchor.ConstraintEqualTo(imageView.LeadingAnchor, (nfloat)(padding + imageView.Frame.Width)).Active = true; label.TopAnchor.ConstraintEqualTo(cell.TopAnchor).Active = true; label.BottomAnchor.ConstraintEqualTo(cell.BottomAnchor).Active = true; return(cell); }