viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Deladd(v,i);
return true;
}
});
public void Deladd(final View view, final int position){
final float x = view.getX();
ObjectAnimator translationX = ObjectAnimator.ofFloat(view, "translationX", 0, 500);
translationX.setDuration(2000);
translationX.start();
translationX.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
listBeans.remove(position);
notifyDataSetChanged();
view.setX(x);
if (delCilck!=null){
delCilck.mydel(view,position);
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
// 接口
private DelCilck delCilck;
public void setDelCilck(DelCilck delCilck) {
this.delCilck = delCilck;
}
public interface DelCilck{
void mydel(View view,int position);
}
属性动画删除
最新推荐文章于 2021-06-21 11:34:53 发布