在listview点击事件中,很多时候需要点击后产生动画效果。在adapter里加入以下代码传入相关值就行。
现要实现点击item后item的消失动画。但是Log发现会删除两条UI数据一条原始数据。参考他人代码及看源码追踪如下
动画监听方法:
private void removeListItem(View rowView, final int position) {
final Animation animation = (Animation) AnimationUtils.loadAnimation(rowView.getContext(), R.anim.floating_main_view_out);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {}
public void onAnimationRepeat(Animation animation) {}
public void onAnimationEnd(Animation animation) {
Message msg = new Message();
msg.what = 2;
msg.arg1 = position;
mhandler.sendMessage(msg);// make the item dismiss.
//animation.cancel();
}
});
rowView.startAnimation(animation);