布局中使用app:overlay="false" 与autoRefresh(); 同时使用会出现NullPointException
Opened this issue · 2 comments
ChineseLincoln commented
报错代码
public void autoRefresh()
{
updateListener();
if(isOverlay)
{
mHeadLayout.getLayoutParams().height = (int) mHeadHeight;
mHeadLayout.requestLayout();
}else
{
createAnimatorTranslationY(mChildView, mHeadHeight, mHeadLayout);
}
}
在程序执行到mHeadLayout.getLayoutParams().height = (int) mHeadHeight; 时出现空指针
布局文件如下
<com.cjj.MaterialRefreshLayout
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buyCarLayout"
android:layout_below="@id/productsOptions"
app:isLoadMore="true"
app:overlay="true"
app:wave_show="false">
<android.support.v7.widget.RecyclerView
android:id="@+id/products"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.cjj.MaterialRefreshLayout>
Joslyn-Chen commented
不能在主线程直接去刷新,作者的demo里有的。
public void autoRefresh() {
if (!isRefreshing) {
this.postDelayed(new Runnable() {
@OverRide
public void run() {
updateListener();
if (isOverlay) {
mHeadLayout.getLayoutParams().height = (int) mHeadHeight;
mHeadLayout.requestLayout();
} else {
createAnimatorTranslationY(mChildView, mHeadHeight, mHeadLayout);
}
}
}, 500);
}
}
gzejia commented
表示直接down下作者的Demo到自己项目当中引用,就不会出现该NullPointException的问题。