huxq17 / XRefreshView

一个万能的android下拉上拉刷新的框架,完美支持recyclerview
1.7k stars 501 forks source link

XRefreshView里拿到listview #77

Closed yunye121 closed 7 years ago

yunye121 commented 7 years ago

getContentView().getContentView() 我看代码XRefreshContentView返回来的应该是一个abslistview,但是我拿到的一直是relativelayout ,不知道为什么,求大神解答

huxq17 commented 7 years ago

你是不是设置了emptyview,并且调用了enableEmptyView(true)?emptyview是Relativelayout?

yunye121 commented 7 years ago

是设置了emptyview并让它显示了,这样怎么拿到listview?设置了emptyview没让它显示怎么拿到listview?

huxq17 commented 7 years ago

listview不能直接通过findviewbyid来获取么?

yunye121 commented 7 years ago

是这样的,我写了一个类来继承XRefresh,把我们用到的一些属性设置一下,我还设置了emptyview,在onRefresh和onLoadMore的时候如果能获取listview就能获取adapter就能获取count,判断count数量就能设置enableEmptyView(true)不用每次在activity中设置了

huxq17 commented 7 years ago

方法有很多,你可以重写onFinishInflate方法,在这里面getChildAt(1)就是listview

yunye121 commented 7 years ago

好的,非常感谢