我创建了一个列表视图,并且通过滑动删除了项目。我添加了一个动画来滑动。当我在列表视图的所有项目上滑动动画时,而不是我刷卡的动画。 我想知道我该怎么做!谢谢你的帮助!
noteList.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
historicX = event.getX();
historicY = event.getY();
break;
case MotionEvent.ACTION_UP:
if (event.getX() - historicX < -DELTA) {
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.right);
v.startAnimation(animation);
// removing this notes
dbhelper.removeNote(items.get(position).getId());
// refreshing the listView
setNotes();
return true;
} else if (event.getX() - historicX > DELTA) {
// removing this notes
dbhelper.removeNote(items.get(position).getId());
// refreshing the listView
setNotes();
return true;
}
break;
default:
return false;
}
return false;
}
});