一些bug结合PullToRefresh和SwipeListView库时出现 [英] some bugs appeared when combining PullToRefresh and SwipeListView library
问题描述
我有同时实现 PullToRefresh 的(旧)的列表和的 SwipeListView 库。
林如下的<一个href=\"https://$c$c.google.com/p/fitup/source/browse/android/trunk/libprojects/PullToRefresh/src/com/handmark/pulltorefresh/library/PullToRefreshSwipeListView.java?r=279\"相对=nofollow>这个来组合这些库和<一个href=\"https://$c$c.google.com/p/fitup/source/browse/android/trunk/src/fitup/app/ui/monitor/UiUsers.java?r=279\"相对=nofollow>此内容在活动使用它
。
我的列表可以做一些基本的功能像上拉/下拉和刷卡左/右,但我遇到了一些bug:
- 在我的列表视图中的项目位置总是从1日开始,我相信它应该从0开始,所以我需要减少它在我的方法。
- 当我刷卡的项目(例如,第一个项目),该项目第5项将被刷卡来。因此指数+ 4项目也将被刷卡。
在$ C C I用于初始化对象:
私人PullToRefreshSwipeListView ptrListView;
私人SwipeListView resultListView;resultListView = ptrListView.getRefreshableView();
ptrListView.setOnRefreshListener(新OnRefreshListener2&LT; SwipeListView&GT;(){ @覆盖
公共无效onPullDownToRefresh(PullToRefreshBase&LT; SwipeListView&GT; refreshView){
// TODO自动生成方法存根 } @覆盖
公共无效onPullUpToRefresh(PullToRefreshBase&LT; SwipeListView&GT; refreshView){
// TODO自动生成方法存根 } });
这是我用来初始化列表视图的方法:
私人无效setListview(){
适配器=新LibraryAdapter(这一点,R.layout.item_library_list,新的ArrayList&LT; PurchasedItem&GT;(),resultListView);
adapter.setListener(新LibraryListListener(){
//设置适配器 }); resultListView.setSwipeListViewListener(新BaseSwipeListViewListener(){
//位置迪-1林嘉欣sejak gabung库swipelistview + pulltorefresh,位置slalu kelebihan 1安培; menyebabkan OutOfBound错误。 @覆盖
公共无效onClickFrontView(最终诠释位置){
//这里做什么
} @覆盖
公共无效onOpened(INT位置,布尔toRight){
// TODO自动生成方法存根
super.onOpened(位置1,toRight);
lastPos =位置1;
} @覆盖
公共无效onMove(INT位置,浮X){
// TODO自动生成方法存根
super.onMove(位置1中,x);
} @覆盖
公众诠释onChangeSwipeMode(INT位置){
// TODO自动生成方法存根
返回SwipeListView.SWIPE_MODE_DEFAULT;
} @覆盖
公共无效onStartOpen(INT位置,诠释行动,布尔右){
// TODO自动生成方法存根
super.onStartOpen(位置1,动作,右); } }); resultListView.setOnItemLongClickListener(新OnItemLongClickListener(){ @覆盖
公共布尔onItemLongClick(适配器视图&LT;&GT;适配器,查看ARG1,
最终诠释POS,长ARG3){
//这里做什么 }
}); ptrListView.setAdapter(适配器);
ptrListView.setLongClickable(真);
resultListView.setSwipeOpenOnLong preSS(假);
}
这是我的xml:
&LT; com.handmark.pulltorefresh.library.PullToRefreshSwipeListView
的xmlns:刷卡=http://schemas.android.com/apk/res-auto
的xmlns:PTR =http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID /列表
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@机器人:彩色/透明
机器人:cacheColorHint =@机器人:彩色/透明
机器人:分=@绘制/ line_separator_repeat
机器人:listSelector =#00000000
PTR:ptrMode =pullFromEnd
刷卡:swipeActionLeft =兜底
刷卡:swipeBackView =@ + ID /后退
刷卡:swipeCloseAllItemsWhenMoveList =真
刷卡:swipeFrontView =@ + ID /战线
刷卡:swipeMode =既/&GT;
请好心帮我,任何帮助是AP preciated。谢谢
我有同样的第一个问题喜欢你。我认为第一项(索引0)是头。
INT _index =指数 - listView.getHeaderViewsCount();
我从来没有见过你的第二个问题。您可以尝试使用此方法解决问题动人:
<$p$p><$c$c>listView.setOnScrollListener(listView.getRefreshableView().getTouchListener().makeScrollListener());希望这有助于
I have a list that implementing both of PullToRefresh (the old one) and SwipeListView library.
Im following this to combining those library and this to use it in the Activity
.
My list can do some basic functionalities like pullUp/pullDown and swipe left/right but i encountered some bug :
- The item position in my listview is always started from 1, i believe it should be started from 0, so i need to decrease it in my methods.
- When i swipe an item (say, the first item), the item 5th item will be swiped to. So the index+4 item will also be swiped.
The code i used to initialize the objects :
private PullToRefreshSwipeListView ptrListView;
private SwipeListView resultListView;
resultListView = ptrListView.getRefreshableView();
ptrListView.setOnRefreshListener(new OnRefreshListener2<SwipeListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<SwipeListView> refreshView) {
// TODO Auto-generated method stub
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<SwipeListView> refreshView) {
// TODO Auto-generated method stub
}
});
This is the method i used to initialize the listview :
private void setListview() {
adapter = new LibraryAdapter(this, R.layout.item_library_list, new ArrayList<PurchasedItem>(), resultListView);
adapter.setListener(new LibraryListListener() {
//set the adapter
});
resultListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
//position di -1 karena sejak gabung library swipelistview + pulltorefresh, position slalu kelebihan 1 & menyebabkan OutOfBound error.
@Override
public void onClickFrontView(final int position) {
//do something here
}
@Override
public void onOpened(int position, boolean toRight) {
// TODO Auto-generated method stub
super.onOpened(position-1, toRight);
lastPos = position-1;
}
@Override
public void onMove(int position, float x) {
// TODO Auto-generated method stub
super.onMove(position-1, x);
}
@Override
public int onChangeSwipeMode(int position) {
// TODO Auto-generated method stub
return SwipeListView.SWIPE_MODE_DEFAULT;
}
@Override
public void onStartOpen(int position, int action, boolean right) {
// TODO Auto-generated method stub
super.onStartOpen(position-1, action, right);
}
});
resultListView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapter, View arg1,
final int pos, long arg3) {
//do something here
}
});
ptrListView.setAdapter(adapter);
ptrListView.setLongClickable(true);
resultListView.setSwipeOpenOnLongPress(false);
}
And this is my xml :
<com.handmark.pulltorefresh.library.PullToRefreshSwipeListView
xmlns:swipe="http://schemas.android.com/apk/res-auto"
xmlns:ptr="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:divider="@drawable/line_separator_repeat"
android:listSelector="#00000000"
ptr:ptrMode="pullFromEnd"
swipe:swipeActionLeft="reveal"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeFrontView="@+id/front"
swipe:swipeMode="both" />
Please kindly help me, any help is appreciated. Thanks
I had the same first issue like you. i think the first item (index 0) is the header.
int _index = index - listView.getHeaderViewsCount();
I had never met your second problem. You can try this to solve touching problems :
listView.setOnScrollListener(listView.getRefreshableView().getTouchListener().makeScrollListener());
Hope this help
这篇关于一些bug结合PullToRefresh和SwipeListView库时出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!