Open karunanaik opened 7 years ago
@karunanaik It's some bug with onLayout. It thinks the RecyclerView has been set. Found a work around: create your own CustomFastScroller extends FastScroller
, then override onLayout
:
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (recyclerView != null) {
super.onLayout(changed, l, t, r, b);
}
}
Also,
@Override
public void setRecyclerView(RecyclerView recyclerView) {
this.recyclerView = recyclerView;
super.setRecyclerView(recyclerView);
requestLayout();
}
then call setRecyclerView
on your CustomFastScroller.
I got same error.But i fixed by using above code.The below code working fine.Thanks @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if (recyclerView != null) { super.onLayout(changed, l, t, r, b); } } Also,
@Override public void setRecyclerView(RecyclerView recyclerView) { this.recyclerView = recyclerView; super.setRecyclerView(recyclerView);
requestLayout();
}
java.lang.NullPointerException at com.futuremind.recyclerviewfastscroll.RecyclerViewScrollListener.updateHandlePosition(RecyclerViewScrollListener.java:47) at com.futuremind.recyclerviewfastscroll.FastScroller.onLayout_Original(FastScroller.java:168) at com.futuremind.recyclerviewfastscroll.FastScroller.onLayout(FastScroller.java:-1) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.support.constraint.ConstraintLayout.onLayout_Original(ConstraintLayout.java:1127) at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java:-1) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612)
I get the above null pointer exception in my design view.
Below is my xml:
` <RelativeLayout android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/callScheduleType">
Can you please help me and let me know what am I missing here?