简体   繁体   English

如何在带有自定义ArrayAdapter的ListView中使用ViewPropertyAnimator?

[英]How can I use ViewPropertyAnimator in a ListView with a custom ArrayAdapter?

I have a custom ArrayAdapter populating a ListView . 我有一个自定义ArrayAdapter填充ListView Here it is: 这里是:

public class FilesAdapter extends ArrayAdapter<PutioFileLayout> {

    Context context;
    int layoutResourceId;
    List<PutioFileLayout> data = null;

    public FilesAdapter(Context context, int layoutResourceId, List<PutioFileLayout> data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        FileHolder holder = null;

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new FileHolder();
            holder.textName = (TextView) row.findViewById(R.id.text_fileListName);
            holder.textDescription = (TextView) row.findViewById(R.id.text_fileListDesc);
            holder.imgIcon = (ImageView) row.findViewById(R.id.img_fileIcon);

            row.setTag(holder);
        } else {
            holder = (FileHolder) row.getTag();
        }

        PutioFileLayout file = data.get(position);
        holder.textName.setText(file.name);
        holder.textDescription.setText(file.description);
        holder.imgIcon.setImageResource(file.icon);

        return row;
    }

    static class FileHolder {
        TextView textName;
        TextView textDescription;
        ImageView imgIcon;
    }
}

I have a Fragment that initializes the custom adapter at first with one item, which says "Loading", then does some network stuff, and finally updates the adapter with the real information. 我有一个Fragment ,首先用一个项目初始化自定义适配器,其中显示“正在加载”,然后执行一些网络操作,最后使用真实信息更新适配器。

I want to have some kind of animation for when the loading is done and the real info comes in. Maybe a simple fade out. 我希望在加载完成和真实信息进入时有一些动画。也许是一个简单的淡出。 But I can't figure out how I can use .animate() on any of my ListView 's rows when this takes place. 但是当我发生这种情况时,我无法弄清楚如何在我的任何ListView行上使用.animate()

How should I go about this? 我该怎么办呢?

在你的回调中,只需:listView.getChildAt(...)。animate();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM