I have a listView, and on each element I added a progressBar, which should disappear after loading the image. But I could not find a way to do this. I tried to make it disappear in the getView class, but it disappears immediately after loading the image.
For example, when adding some views to the scrollView in the AsyncTask 'DoInBackground class, I could load the image, and then onPostExecute I could set the image and then delete the progressBar. It works great. I want to do something similar for listView. Can anyone help me?
I donβt know if I was understandable or not, but I can summarize that I have list_item.xml containing the image and the progress on it. And I want these progressbars to disappear after downloading and installing images.
Thanks for the help.
Here is my adapter class:
class myListAdapter extends ArrayAdapter<Items> {
private ArrayList<Items> items;
private Context ctx;
public myListAdapter(Context context, int textViewResourceId,
ArrayList<Items> items) {
super(context, textViewResourceId, items);
this.ctx = context;
this.items = items;
}
@Override
public int getCount() {
return items.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inf = (LayoutInflater) ctx
.getSystemService(LAYOUT_INFLATER_SERVICE);
v = inf.inflate(R.layout.main_list_item, null);
}
Items index = listContents.get(position);
if (index != null) {
ImageView img = (ImageView) v.findViewById(R.id.listImage);
TextView title = (TextView) v.findViewById(R.id.listTopText);
TextView content = (TextView) v.findViewById(R.id.listDownText);
if (title != null)
title.setText(index.getTitle());
if (content != null)
content.setText(index.getContent());
if (img != null)
img.setImageBitmap(index.getImageBitmap());
((ProgressBar) v.findViewById(R.id.listItemProgressBar)).setVisibility(View.GONE);
}
return v;
}
}
So, in this line below, I make a progress bar, but it should disappear after downloading and installing the image ... But there are no progressive bars in the added list items, what is my problem ??
((ProgressBar) v.findViewById(R.id.listItemProgressBar)).setVisibility(View.GONE);
yahya source
share