ListView - ItemLongPress

2 posts, 1 answers
  1. Matt
    Matt avatar
    5 posts
    Member since:
    Aug 2017

    Posted 10 Jan 2018 Link to this post

    I'm looking for a way to get an ItemLongPress similar to the ItemTapped that is provided for android only (but accessible in through Forms).

    I tried making a custom renderer and it is being used (I put a breakpoint in an override of the OnElementChanged in the customer renderer and it's being called), but I'm not getting any touch events.  I tried overriding the OnTouchEvent (breakpoint never hits) and I tried Control.SetOnLongClickListener inside the OnElementChanged event (after setting LongClickable = true), but the breakpoint in my new Long Click Listener never hits. 

    Code snippets from the custom renderer (not entire code, but this is where I've set breakpoints):

            protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Telerik.XamarinForms.DataControls.RadListView> e)
                if (e.NewElement != null) {
                    if (Control != null) {
                        Control.Clickable = true;
                        Control.LongClickable = true;


            private class RadLongClickListener : Java.Lang.Object, Android.Views.View.IOnLongClickListener
                public static readonly Lazy<RadLongClickListener> Instance = new Lazy<RadLongClickListener>(() => new RadLongClickListener());

                public bool OnLongClick(Android.Views.View v)
                    var renderer = v.Tag as ExtendedRadListRenderer;
                    return true;


      public override bool OnTouchEvent(MotionEvent e)
                return base.OnTouchEvent(e);

  2. Answer
    Tsvyatko avatar
    863 posts

    Posted 15 Jan 2018 Link to this post

    Hello Matt,

    Thank you for contacting us! In order to enable the listview long-press you would need the following code in the custom renderer:
    Control.ListView.AddItemClickListener(new RadLongClickListener(this));

    I have prepared sample project demonstrating how this can be achieved. Check the attachment and let us know if this helps.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top