protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.ListView> e) { base.OnElementChanged(e); if (e.OldElement != null) { // Unsubscribe } if (e.NewElement != null) { fListView = e.NewElement as FListView; uiTableView = Control; //Control.AllowsSelection = false; uiTableView.AllowsMultipleSelection = true; uiTableView.Delegate = new FListViewDelegate(fListView); longPressGesture = new UILongPressGestureRecognizer(ItemLongPress); var obj = this; var d = ViewController; string s = string.Empty; } }
private void FlyImages_Click(object sender, EventArgs e) { bool isSelected = FListView.IsSelectedItem(Position); var setRightOut = (AnimatorSet)AnimatorInflater.LoadAnimator(Context, Resource.Animator.right_out); var setLeftIn = (AnimatorSet)AnimatorInflater.LoadAnimator(Context, Resource.Animator.left_in); if (!isSelected) { setRightOut.SetTarget(ImgUser); setLeftIn.SetTarget(ImgBack); setRightOut.Start(); setLeftIn.Start(); //this.SetBackgroundColor(Android.Graphics.Color.AliceBlue); FListView.MarkItemAsSelected(Position, true); } else { setRightOut.SetTarget(ImgBack); setLeftIn.SetTarget(ImgUser); setRightOut.Start(); setLeftIn.Start(); //this.SetBackgroundColor(Android.Graphics.Color.White); FListView.MarkItemAsSelected(Position, false); } FListView.UpdateActionModeDroid(); }
protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context) { var xfNotificationCell = (XFNotificationViewCell)item; AListView listView = parent as AListView; FListView fListView = item.Parent as FListView; cell = convertView as NotificationViewCellDroid; if (cell == null) { cell = new NotificationViewCellDroid(context, xfNotificationCell, fListView, listView); } else { cell.XFNotificationCell.PropertyChanged -= OnNativeCellPropertyChanged; cell.Position = listView.GetPositionForView(cell); } xfNotificationCell.PropertyChanged += OnNativeCellPropertyChanged; cell.Position = (fListView.ItemsSource as IList).IndexOf(xfNotificationCell.Person); cell.UpdateCell(xfNotificationCell); return(cell); }
public NotificationViewCellDroid(Context context, XFNotificationViewCell cell, FListView fListView, AListView listView) : base(context) { XFNotificationCell = cell; FListView = fListView; AListView = listView; var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.NotificationItem, null); //Get views to each control ItemTemplate TxtName = view.FindViewById <TextView>(Resource.Id.txtName); TxtAge = view.FindViewById <TextView>(Resource.Id.txtAge); ImgUser = view.FindViewById <ImageView>(Resource.Id.imgUser); ImgBack = view.FindViewById <ImageView>(Resource.Id.imgBack); FlyImages = view.FindViewById <FrameLayout>(Resource.Id.flyImages); FlyImages.Click += FlyImages_Click; float scale = (context as Activity).Resources.DisplayMetrics.Density; FlyImages.SetCameraDistance(8000 * scale); AddView(view); }
public void UpdateCell(XFNotificationViewCell cell) { Person person = cell.Person; TxtName.Text = person.Name; TxtAge.Text = person.Age.ToString(); // Dispose of the old image if (ImgUser.Drawable != null) { using (var image = ImgUser.Drawable as BitmapDrawable) { if (image != null) { if (image.Bitmap != null) { image.Bitmap.Dispose(); } } } } if (FListView.IsSelectedItem(Position)) { ImgUser.Alpha = 0; ImgBack.Alpha = 1; //this.SetBackgroundColor(Android.Graphics.Color.AliceBlue); //FlyImages_Click(FlyImages, EventArgs.Empty); } else { ImgUser.Alpha = 1; ImgBack.Alpha = 0; //this.SetBackgroundColor(Android.Graphics.Color.White); //FlyImages_Click(FlyImages, EventArgs.Empty); } SetImage(person.ImageUrl); }
protected override void OnElementChanged(ElementChangedEventArgs <XFListView> e) { base.OnElementChanged(e); if (e.OldElement != null) { // unsubscribe //Only enable hardware accelleration on lollipop if ((int)Build.VERSION.SdkInt < 21) { SetLayerType(LayerType.Software, null); } } if (e.NewElement != null) { // Configure the native control and subscribe to event handlers fListView = Element as FListView; nativeListView = Control as NListView; if (fListView.MultiSelect) { //1º //nativeListView.ChoiceMode = ChoiceMode.MultipleModal; //nativeListView.SetMultiChoiceModeListener(new MultiChoiceModeListener(Context, nativeListView, fListView)); //2º nativeListView.ItemClick += NativeListView_ItemClick; nativeListView.ItemLongClick += NativeListView_ItemLongClick; fListView.OnUpdateActionModeDroid += FListView_OnUpdateActionModeDroid; //ActionMode = new ActionMode(); //((Activity)Context).StartActionMode(new ActionModeCustom(Context, fListView)); Toast.MakeText(Context, "Multiselect ListView activated !", ToastLength.Short).Show(); } } }
public FListViewDelegate(FListView fListView) { FListView = fListView; }
public MultiChoiceModeListener(Context context, NListView nativeListView, FListView fListView) { Context = context; FListView = fListView; NativeListView = nativeListView; }
public ActionModeCustom(Context context, FListView fListView) { Context = context; FListView = fListView; }