Android-MaterialRefreshLayout icon indicating copy to clipboard operation
Android-MaterialRefreshLayout copied to clipboard

布局中使用app:overlay="false" 与autoRefresh(); 同时使用会出现NullPointException

Open ChineseLincoln opened this issue 9 years ago • 2 comments

报错代码

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>

ChineseLincoln avatar Nov 24 '15 06:11 ChineseLincoln

不能在主线程直接去刷新,作者的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); } }

Joslyn-Chen avatar Dec 17 '15 08:12 Joslyn-Chen

表示直接down下作者的Demo到自己项目当中引用,就不会出现该NullPointException的问题。

gzejia avatar Jun 23 '16 01:06 gzejia