问题描述
我的建筑物pulltorefresh和stickylistHeaders都need.i已经实现了应用程序的pulltorefresh,但我不能使它与stickyListHeaders.Is工作,有可能合并这两个库的应用程序?或者是有什么替代方案?任何想法?
I building an app where pulltorefresh and stickylistHeaders are both need.i have implemented the pulltorefresh in the app but am not able to make it work with stickyListHeaders.Is it possible to merge the two libraries?Or is there any alternative?any Ideas?
推荐答案
我的实现是在更新这两个库后打破了。这是我的速战速决,以使其能够工作。 任何建议和改进,欢迎!
My implementation was broken after updating both libraries, too. This is my quick fix to make it work again. Any suggestions and improvements are welcome!
-
请一个新的类,延长SticklistListHeadersListView并实现从动作条,PullToRefresh的ViewDelegate接口:
Make a new class and extend the SticklistListHeadersListView and implement the ViewDelegate interface from ActionBar-PullToRefresh:
public class PtrStickyListHeadersListView extends StickyListHeadersListView
implements ViewDelegate {
public PtrStickyListHeadersListView(Context context) {
super(context);
}
public PtrStickyListHeadersListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PtrStickyListHeadersListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isReadyForPull(View view, float v, float v2) {
View childView = getWrappedList().getChildAt(0);
int top = (childView == null) ? 0 : childView.getTop();
return top >= 0;
}
}
而在你的 layout.xml
替换
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
...>
与
<com.yourapp.package.foo.PtrStickyListHeadersListView
...>
而在最后,添加代理:(的ListView
是PtrStickyListHeadersListView的一个实例)的
And at last, add the delegate: (listView
is an instance of PtrStickyListHeadersListView)
ActionBarPullToRefresh.from(getActivity())
// We need to insert the PullToRefreshLayout into the Fragment 's ViewGroup
.insertLayoutInto(viewGroup)
// We need to mark the ListView and it 's Empty View as pullable
// This is because they are not dirent children of the ViewGroup
.theseChildrenArePullable(R.id.your_list_id)
// We can now complete the setup as desired
.listener(...)
.useViewDelegate(PtrStickyListHeadersListView.class, listView)
.setup(mPullToRefreshLayout);
这篇关于是有可能合并stickylistviewheader与crisbanes pulltorefresh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!