lcodecorex / TwinklingRefreshLayout

RefreshLayout that support for OverScroll and better than iOS. 支持下拉刷新和上拉加载的RefreshLayout,自带越界回弹效果,支持RecyclerView,AbsListView,ScrollView,WebView
Apache License 2.0
4k stars 672 forks source link

通过代码new TwinklingRefreshLayout之后下拉会闪退 #78

Open gaoweiqiao opened 7 years ago

gaoweiqiao commented 7 years ago

initGestureDetector()方法只在解析xml之后调用,而new 出来的调用不着这个方法.

lcodecorex commented 7 years ago

你好!请问具体的使用场景是什么呢?因为如果不通过inflate的方式,就没有列表控件。

stonewords commented 7 years ago

public class FixTwinkRefreshLayout extends TwinklingRefreshLayout {

public FixTwinkRefreshLayout(Context context) {
    super(context);
    init();
}

private void init() {
    //修复使用new FixTwinkRefreshLayout(Context context) 没有初始化onFinishInflate里面的内容从而导致Crash
    post(new Runnable() {
        @Override
        public void run() {
            onFinishInflate();
        }
    });
}

}

目前采用这种方式可以解决,但没有在项目中实践,有待测试