Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Inflating Class Error while trying to create a Custom View

$
0
0

I need to create a custom view extending HorizontalScrollView class, to intercept it's touch event. So I converted this code (Second answer) as follows: public class CustomScrollView : HorizontalScrollView { private float xDistance, yDistance, lastX, lastY; public CustomScrollView(Context context, IAttributeSet attrs) : base(context, attrs) { }

    public override bool OnInterceptTouchEvent(MotionEvent ev)
    {
        switch (ev.Action)
        {
        case MotionEventActions.Down:
            xDistance = yDistance = 0f;
            lastX = ev.GetX();
            lastY = ev.GetY();
            break;
        case MotionEventActions.Move:
            float curX = ev.GetX ();
            float curY = ev.GetY ();
            xDistance += Math.Abs (curX - lastX);
            yDistance += Math.Abs (curY - lastY);
            lastX = curX;
            lastY = curY;
            if (xDistance > yDistance) {
                return false;
            }
            break;
        }

        return base.OnInterceptTouchEvent(ev);
    }
}

It's throwing a "Inflating Class" error. What is the problem with this code?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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