我使用ItemTouchHelper在recycleview上获取滑动方向以执行事件。因为我不需要任何动画,所以我重写getSwipeDirs()并相应地修改它。它停止了动画,但它也停止了更新的滑动方向(总是给出相同的方向)。
这是一段代码:
ItemTouchHelper mImageTouchHelper = new ItemTouchHelper(
new ItemTouchHelper.SimpleCallback(ItemTouchHelper.RIGHT,
ItemTouchHelper.LEFT) {
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
if(direction == ItemTouchHelper.LEFT){
moveToHomeScreen();
}
}
public boolean onMove(RecyclerView recyclerview, RecyclerView.ViewHolder v, RecyclerView.ViewHolder target) {
return false;
}
@Override public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
onSwiped(viewHolder, super.getSwipeDirs(recyclerView, viewHolder));
return 0;
}
});
mImageTouchHelper.attachToRecyclerView(recycleView);
答案 0 :(得分:0)
尝试将您的构造函数更改为:
<div id="NoveMeses" data-ng-if=$odd class="tableRowOdd" data-ng-show="item.TipoOWS === '9M'">
<div class="tableCellContent20">
<h3 class="cellTextType" ><span>{{::item.TipoCalculado.split('#')[1]}}</span></h3>
</div>
<div id="row1" class="tableCellContent20">
<h3 class="cellTextValue" data-ng-show="item.TipoOWS !== 'Datas'"><span>{{::item.Last.replace('.',',') | limitTo:7:0}}</span></h3>
<h3 class="cellTextValue" data-ng-show="!item.TipoOWS !== 'Datas'"><span>N.A.</span></h3>
</div>
<div id="row2" class="tableCellContent20">
<h3 class="cellTextValue" data-ng-show="item.TipoOWS !== 'Datas'"><span>{{::item.LastUm.replace('.',',') | limitTo:7:0}}</span></h3>
<h3 class="cellTextValue" data-ng-show="!item.TipoOWS !== 'Datas'"><span>N.A.</span></h3>
</div>
</div>
SimpleCallback构造函数的第一个参数负责拖动标志,第二个参数负责滑动标志。