Android的 - 动画,同时去除的ListView项目 [英] Android - Animation while removing items from ListView

查看:158
本文介绍了Android的 - 动画,同时去除的ListView项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个活动一个ListView。在每个项目有一个文本和一个复选框。在点击复选框,我想从ListView中删除的项目,并希望添加动画,例如滑下或淡出,然后删除。

I have a ListView in an activity. In each list item there are a text and a CheckBox. On click on the CheckBox, I want to remove the item from the ListView and want to add an animation such as slide down or fade out and then remove.

任何帮助吗?

推荐答案

有一个在我的答案

protected void removeListItem(View rowView, final int positon) {
    // TODO Auto-generated method stub

    final Animation animation = AnimationUtils.loadAnimation(rowView.getContext(), R.anim.splashfadeout);
    rowView.startAnimation(animation);
    Handler handle = new Handler();
    handle.postDelayed(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            array.remove(positon);
            adapter.notifyDataSetChanged();
            animation.cancel();
        }
    }, 1000);
}

呼叫 removeListItem(查看rowView,最终诠释当前位置)在onItem点击ListView控件的方法

call removeListItem(View rowView, final int positon) method in onItem click of ListView

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView <? > parent, View rowView, int positon, long id) {
        // TODO Auto-generated method stub
        Toast.makeText(rowView.getContext(), "" + positon, Toast.LENGTH_LONG).show();

        removeListItem(rowView, positon);


    }
});

和RES /动画/ splashfadeout.xml

and res/anim/splashfadeout.xml

  <?xml version="1.0" encoding="utf-8" ?> 
  <alpha xmlns:android="http://schemas.android.com/apk/res/android" 
  android:interpolator="@android:anim/decelerate_interpolator" 
  android:zAdjustment="top" 
  android:fromAlpha="1.0" 
  android:toAlpha="0.0" 
  android:duration="2000" />

动画的ListView 听到

这篇关于Android的 - 动画,同时去除的ListView项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆