在Recyclerview中更新进度条

时间:2015-10-30 00:45:44

标签: android android-recyclerview

我想更新recyclerview项目中的进度条。 现在我不知道如何在一个项目中获取进度条并从另一个类更新它,该类与此适配器无关。

这是我的代码:

public class TransmissionAdapter extends RecyclerView.Adapter<TransmissionAdapter.ViewHolderUI> {

    public static class ViewHolderUI extends RecyclerView.ViewHolder{

        ImageView fileTypeImage;
        TextView fileName;
        TextView progressDescription;
        TextView timeAgoTrans;
        ProgressBar uploadProgess;

        public ViewHolderUI(View itemView) {
            super(itemView);

            fileTypeImage = (ImageView) itemView.findViewById(R.id.file_type_image);
            fileName = (TextView) itemView.findViewById(R.id.file_name);
            progressDescription = (TextView) itemView.findViewById(R.id.progress_description);
            timeAgoTrans = (TextView) itemView.findViewById(R.id.time_ago_trans);
            uploadProgess = (ProgressBar) itemView.findViewById(R.id.progress_bar_transmission);
        }

    }


    @Override
    public ViewHolderUI onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_view, null);

        return new ViewHolderUI(itemView);
    }

    @Override
    public void onBindViewHolder(ViewHolderUI holder, int position) {

        holder.fileName.setText(TransmissionsView.itemTexte.get(position));
    }

    @Override
    public int getItemCount() {
        return TransmissionsView.itemTexte.size();
    }


}

我尝试将进度放在arraylist中并使用notifyDataSetChanged更新recyclelerlist中的进度,并在“onBindViewHolder”方法中设置当前进度。但是如果进度条是要快速UI线程跳过帧,那么这是正确的方法吗?!

0 个答案:

没有答案