NullPointerException occurs when using layoutparams without checking it in createPinnedShadow method,
and I fixed it by adding the codes below:
final ViewGroup.LayoutParams vlp = pinnedView.getLayoutParams();
AbsListView.LayoutParams lp;
if (vlp == null) {
lp = (LayoutParams) generateDefaultLayoutParams();
} else if (!checkLayoutParams(vlp)) {
lp = (LayoutParams) generateLayoutParams(vlp);
} else {
lp = (LayoutParams) vlp;
}
pinnedView.setLayoutParams(lp);
BETWEEN
// request new view
View pinnedView = getAdapter().getView(position, recycleView, PinnedSectionListView.this);
AND
// read layout parameters
LayoutParams layoutParams = (LayoutParams) pinnedView.getLayoutParams();
NullPointerException occurs when using layoutparams without checking it in createPinnedShadow method, and I fixed it by adding the codes below: final ViewGroup.LayoutParams vlp = pinnedView.getLayoutParams(); AbsListView.LayoutParams lp; if (vlp == null) { lp = (LayoutParams) generateDefaultLayoutParams(); } else if (!checkLayoutParams(vlp)) { lp = (LayoutParams) generateLayoutParams(vlp); } else { lp = (LayoutParams) vlp; } pinnedView.setLayoutParams(lp); BETWEEN // request new view View pinnedView = getAdapter().getView(position, recycleView, PinnedSectionListView.this); AND // read layout parameters LayoutParams layoutParams = (LayoutParams) pinnedView.getLayoutParams();