public static RestaurantMenuItemDialogFragment NewInstance(int id, int resId) { RestaurantMenuItemDialogFragment f = new RestaurantMenuItemDialogFragment(); Bundle args = new Bundle(); args.PutInt("id", id); args.PutInt("resId", resId); f.Arguments = args; return(f); }
private void Setup() { if (restaurant != null) { LinearLayout imageLayout = view.FindViewById <LinearLayout>(Resource.Id.restaurant_view_images); if (restaurant.ImageIds.Any()) { foreach (int imageId in restaurant.ImageIds) { View imgView = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_image, null); ImageView img = imgView.FindViewById <ImageView>(Resource.Id.restaurant_view_img); Image dbImg = _imageFacade.LoadImage(imageId).Result; if (dbImg == null) { img.SetImageResource(Resource.Drawable.nophoto); } else { img.SetImageBitmap(BitmapFactory.DecodeByteArray(dbImg.FileContent, 0, dbImg.FileContent.Length)); } imageLayout.AddView(img); View divider = LayoutInflater.From(Activity).Inflate(Resource.Layout.vertical_divider_full, null); imageLayout.AddView(divider); } } else { View imgView = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_image, null); ImageView img = imgView.FindViewById <ImageView>(Resource.Id.restaurant_view_img); img.SetImageResource(Resource.Drawable.nophoto); imageLayout.AddView(img); } view.FindViewById <TextView>(Resource.Id.restaurant_view_name).Text = restaurant.Name; view.FindViewById <TextView>(Resource.Id.restaurant_view_phone).Text = restaurant.PhoneNo; view.FindViewById <TextView>(Resource.Id.restaurant_view_address).Text = restaurant.AddressStreet + ", " + restaurant.AddressTown + ", " + restaurant.AddressCounty + ", " + restaurant.AddressPostalCode; LinearLayout container = view.FindViewById <LinearLayout>(Resource.Id.restaurant_view_menu_container); foreach (var cat in types) { View viewCat = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_menu, null); LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 16 }; viewCat.LayoutParameters = layout; viewCat.FindViewById <TextView>(Resource.Id.restaurant_view_menu_type).Text = cat.Name; container.AddView(viewCat); viewCat.Click += delegate { MainActivity.IsNavDisabled = true; IsActive = false; Android.App.DialogFragment dialog = RestaurantMenuItemDialogFragment.NewInstance(cat.Id, restaurant.Id); dialog.Show(FragmentManager, "fragmentDialog"); }; } } }