Here, I have a list (PullToRefreshSwipeListView) that implementing both of PullToRefresh  and SwipeListView library.
List can do some basic functionality like pullUp/pullDown and swipe left/right.
If you decide to use PullToRefreshSwipeListView as a view, you can define it in your xml layout like this:
private PullToRefreshSwipeListView ptrList;
private SwipeListView swipeList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_list);
ptrList = (PullToRefreshSwipeListView)findViewById(R.id.sphr_listview);
swipeList = ptrList.getRefreshableView();
ptrList.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
}
});
}
set adapter in list-view as shown below.
List can do some basic functionality like pullUp/pullDown and swipe left/right.
If you decide to use PullToRefreshSwipeListView as a view, you can define it in your xml layout like this:
 <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" //raw back view
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeFrontView="@+id/front" // raw front view
        swipe:swipeMode="both" />
swipeFrontView- Required - front view id.swipeBackView- Required - back view id.swipeActionLeft- Optional - left swipe action Default: 'reveal'swipeActionRight- Optional - right swipe action Default: 'reveal'swipeMode- Gestures to enable or 'none'. Default: 'both'swipeCloseAllItemsWhenMoveList- Close revealed items on list motion. Default: 'true'swipeOpenOnLongPress- Reveal on long press Default: 'true'swipeAnimationTime- item drop animation time. Default: android configurationswipeOffsetLeft- left offsetswipeOffsetRight- right offset
private PullToRefreshSwipeListView ptrList;
private SwipeListView swipeList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_list);
ptrList = (PullToRefreshSwipeListView)findViewById(R.id.sphr_listview);
swipeList = ptrList.getRefreshableView();
ptrList.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
}
});
}
set adapter in list-view as shown below.
  private void setListData() {
   adapter = new DataAdapter(this, R.layout.item_library_list, new ArrayList<PurchasedItem>(), resultListView);
    
    swipeList.setSwipeListViewListener(new BaseSwipeListViewListener() {   
     @Override
        public void onClickFrontView(final int position) {
            //do something here on Frontview click
        } 
       @Override
        public void onClickBackView(final int position) {
            //do something here on Backview click
        } 
      @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);
        }
    });
    ptrList.setAdapter(adapter); 
    ptrList.setLongClickable(true); 
    swipeList.setSwipeOpenOnLongPress(false);  
    }
hi am doing d same functionalities in my application, i have already used pull to refresh and swipe listview libraries from git hub.... now to do both the functions together, should i
ReplyDeleteuse anyother libraries????
I have posted both libs.please check.
DeleteThis comment has been removed by the author.
DeleteI got an error in your library file...!!!
DeleteHow to get the project?
ReplyDeleteIf i implemented your library in my listview than list items are not clickable. what can i do?
ReplyDeleteThis blog post provides a clear and concise explanation of how to implement both PullToRefresh and SwipeListView functionality in Android.
ReplyDelete