3

私が使用し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しています。注文以外はうまく機能します。私がすべての部分をコメントすると、すべてがうまくいきます。arrayProgressBarconvertView

4

0 に答える 0