动画ListView中新添加的项目 [英] Animate newly added items in ListVIew

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

问题描述

我如何制作动画新添加的项目在的ListView

How can I animate newly added items in ListView?

我有一个适配器,当我在列表中添加新项目,我说 adapter.notifyDataSetChanged(); 在项目的增加,一切都运行完美,但我的问题是我希望新加入的元素有一定的动画。

I have a adapter and when I add new items in my list I say adapter.notifyDataSetChanged(); the items are added, everything works perfectly, but my problem is I want newly added element to have some animation.

推荐答案

动画中每增加一个元素 getView()的方法,你的自定义适配器

Animate each added element in the getView() method of your Custom Adapter.

public View getView(int position, View convertView, ViewGroup parent) {

    View v = convertView;

    if (v == null) {
        LayoutInflater vi = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.simple_list_item_1, null);
    }

    ListData o = list.get(position);
    TextView tt = (TextView) v.findViewById(R.id.toptext);

    tt.setText(o.content);

    Log.d("ListTest", "Position : "+position);
   if(flag == false) {
    Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_top_to_bottom);
    v.startAnimation(animation);}
    return v;
}

,从而实现了动画

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

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