Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Selecting Text of a Label by LongPress

$
0
0

Is it possible to long press a label and select Text on a Label?

I did some rendering on Android. It worked well with one line Labels. But when the Label gets more than one line I get this error message:
“TextView does not support text selection. Action mode cancelled”

I need this function on iOS as well. But I couldn't manage it on iOS at all.

public class SelectableLabel : Label
    {
        public SelectableLabel ()
        {
        }
    }

public class SelectableLabelRenderer : LabelRenderer
    {
        protected override void OnElementChanged (ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged (e);
            var native = (TextView)Control;
            native.SetTextIsSelectable (true);
        }
    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>