Skip to content Skip to sidebar Skip to footer

Set Custom List View Inside Nestedscrollview

I am moving to Coordinator Layout and Nested ScrollView and i know to make it work i need to use recycle r view but the thing is i really want to make it possible with old List Vi

Solution 1:

If you really need to use a ListView, you can implement NestedScrollingChild on your Custom ListView.

The following should work:

publicclassNestedScrollingListViewextendsListViewimplementsNestedScrollingChild {

privatefinal NestedScrollingChildHelper mScrollingChildHelper;

publicNestedScrollingListView(Context context) {
   super(context);
   mScrollingChildHelper = newNestedScrollingChildHelper(this);
   setNestedScrollingEnabled(true);
}

publicNestedScrollingListView(Context context, AttributeSet attrs) {
   super(context, attrs);
   mScrollingChildHelper = newNestedScrollingChildHelper(this);
   setNestedScrollingEnabled(true);
}

@OverridepublicvoidsetNestedScrollingEnabled(boolean enabled) {
   mScrollingChildHelper.setNestedScrollingEnabled(enabled);
}

@OverridepublicbooleanisNestedScrollingEnabled() {
   return mScrollingChildHelper.isNestedScrollingEnabled();
}

@OverridepublicbooleanstartNestedScroll(int axes) {
   return mScrollingChildHelper.startNestedScroll(axes);
}

@OverridepublicvoidstopNestedScroll() {
    mScrollingChildHelper.stopNestedScroll();
}

@OverridepublicbooleanhasNestedScrollingParent() {
    return mScrollingChildHelper.hasNestedScrollingParent();
}

@OverridepublicbooleandispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
                                int dyUnconsumed, int[] offsetInWindow) {
    return mScrollingChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed,
        dxUnconsumed, dyUnconsumed, offsetInWindow);
}

@OverridepublicbooleandispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow) {
    return mScrollingChildHelper.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow);
}

@OverridepublicbooleandispatchNestedFling(float velocityX, float velocityY, boolean consumed) {
    return mScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed);
}

@OverridepublicbooleandispatchNestedPreFling(float velocityX, float velocityY) {
    return mScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY);
}
}

Post a Comment for "Set Custom List View Inside Nestedscrollview"