当我使用convertView
它时,它会返回错误的视图项。它返回正确的对象,应该在这个位置。但回报wrong view
。
public View getView(int arg0, View arg1, ViewGroup arg2) {
// for (Capsule capsule : capsules) {
// Log.d(TAG, "Capsule " + capsule.getId() + " progress is " +
// capsule.getProgress());
// }
// Log.d(TAG, "Position of getView is " + arg0);
Capsule c = getItem(arg0);
Log.d(TAG, "Position of getView is " + arg0 + " capsule title is " + c.getTitle());
if (arg1 != null) {
ProgressBar bar = (ProgressBar)
arg1.findViewById(R.id.item_obtained_progressbar);
TextView date = (TextView)
arg1.findViewById(R.id.item_obtained_dateofopen);
if (c.getProgress() > 0) {
bar.setVisibility(View.VISIBLE);
date.setVisibility(View.INVISIBLE);
bar.setProgress(c.getProgress());
}
return arg1;
}
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.item_obtained, null);
itemView.setPadding(0, 30, 0, 0);
ProgressBar bar = (ProgressBar) itemView.findViewById(R.id.item_obtained_progressbar);
bar.setVisibility(View.INVISIBLE);
TextView date = (TextView) itemView.findViewById(R.id.item_obtained_dateofopen);
TextView title = (TextView) itemView.findViewById(R.id.item_obtained_title);
TextView name = (TextView) itemView.findViewById(R.id.item_obtained_name);
ImageView photo = (ImageView) itemView.findViewById(R.id.item_obtained_photo);
ImageView video = (ImageView) itemView.findViewById(R.id.item_obtained_video);
date.setText(c.getSentString());
title.setText(c.getTitle());
name.setText(c.getRealname());
if (!c.hasPhoto) {
photo.setVisibility(View.INVISIBLE);
}
if (!c.hasVideo) {
video.setVisibility(View.INVISIBLE);
}
Log.d(TAG, "Current capsule " + c.getId() + " progress is " + c.getProgress());
if (c.getProgress() > 0) {
bar.setVisibility(View.VISIBLE);
date.setVisibility(View.INVISIBLE);
bar.setProgress(c.getProgress());
}
return itemView;
}
这是我的来源。我在下载文件时正在检索Capsule object
和array
更新。ProgressBar
除了订单,它工作得很好。当我评论部分convertView
一切顺利时。