android - ItemTouchHelper callback -


i have problems understanding callback method of itemtouchhelper called when swipe carditem, dont finish swipe , instead turn normal state.

what have currently:

   @override    public void onswiped(final recyclerview.viewholder viewholder, int direction) {        mcarditemadapter.deletecard(viewholder.getadapterposition(), mrecyclerview);    } 

which removes item adapter.

and:

 @override  public void onchilddraw(canvas c, recyclerview recyclerview, viewholder viewholder, float dx, float dy, int actionstate, boolean iscurrentlyactive) {      log.d("dx =",""+dx);      // can modified      if(dx < -300) {           view v = viewholder.itemview;           relativelayout mlayout = (relativelayout) v.findviewbyid(r.id.card_item_layout_relative_layout);           mlayout.setbackgroundresource(r.color.red);       }       super.onchilddraw(c, recyclerview, viewholder, dx, dy, actionstate, iscurrentlyactive);  } 

what want achieve ? when swipe, background turns red, when release swipe before onswiped called, background stays red, want white again.

hope can me out this.

add additional else clause:

if(dx < -300){...} else { mlayout.setbackgroundresource(r.color.white); }


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -