0

Iam working android and ios application using nativescript application,I was created the customised scrollview with extending android.widget.ScrollView in nativescript angular and i had listeners inside the scrollview.I want to set my customised scrollview listeners and its override methods to the nativescript angular scrollview.How can i set this android customised listeners to scrollview like setting ios delegate methods?

My Customised scrollView java class is:

import android.content.Context;

public class AndScroll extends org.nativescript.widgets.VerticalScrollView
{
    public interface OnEndScrollListener {
        public void onEndScroll(int x,int y);
    }
    private boolean mIsFling;
    private OnEndScrollListener mOnEndScrollListener;

    public AndScroll(Context context)
    {
        super(context)
    }
    @Override
    public void fling(int velocityY) {
        super.fling(velocityY);
        mIsFling = true;
    }
    @Override
    protected void onScrollChanged(int x, int y, int oldX, int oldY) {
        super.onScrollChanged(x, y, oldX, oldY);
        if (mIsFling) {
            if (Math.abs(y - oldY) < 2 || y >= getMeasuredHeight() || y == 0) {
                if (mOnEndScrollListener != null) {
                    mOnEndScrollListener.onEndScroll(x,y);
                }
                mIsFling = false;
            }
        }
    }
    public OnEndScrollListener getOnEndScrollListener() {
        return mOnEndScrollListener;
    }

    public void setOnEndScrollListener(OnEndScrollListener mOnEndScrollListener) {
        this.mOnEndScrollListener = mOnEndScrollListener;
    }


}

Iam want to access my customised class inside my FoodCourt Scroll ts class:

public createNativeView() {
    return this.orientation === "horizontal" ? new org.nativescript.widgets.HorizontalScrollView(this._context) : new org.nativescript.widgets.VerticalScrollView(this._context);
}

How to access My AndScroll java class in my foodcourt class like

new org.nativescript.widgets.VerticalScrollView

1 Answer 1

1

You should use org.nativescript.widgets.VerticalScrollView if you like to preserve the features exposed by ScrollView component while modifying it.

If your aim is to just intercept OnScrollChangedListener then you just have to do it like it's done here in the original source code.

But I don't think you would actually need any of these, scroll event itself gives you the x & y points constantly if that's all you are looking for within OnScrollChangedListener.

Sign up to request clarification or add additional context in comments.

16 Comments

Is VerticalScrollview widget is available in nativescript angular?
It's part of your NativeScript Framework. Angular is a wrapper around the Core Framework just to expose the features of Angular. So anything that's available in Core, should be available for framework.
Ok thank you manoj..and one more question i want to ask you is the verticalscrollview widget only for android?
Yes, it's Android specific native component, like UIScrollView on iOS.
Ok thank you manoj.i am going to try implement the verticalscrollview.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.