android图片异步加载问题 15
主要代码如下:map.put("title","title");map.put("img","imgURL");...List<HashMap<String,Object...
主要代码如下:
map.put("title","title");
map.put("img","imgURL");
...
List<HashMap<String, Object>> list;
private LayoutInflater listContainer;
...
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageTextView imageTextView = null;
if(convertView ==null){
imageTextView = new ImageTextView();
convertView = listContainer.inflate(R.layout.main_img_list, null);
imageTextView.image =(ImageView) convertView.findViewById(R.id.img);
imageTextView.title =(TextView) convertView.findViewById(R.id.title);
convertView.setTag(imageTextView);
}else{
imageTextView = (ImageTextView) convertView.getTag();
}
imageTextView.image.setBackgroundResource(R.drawable.icon);
//此处为默认图片
imageTextView.title.setText((String)list.get(position).get("title"));
this.convertView=convertView;
return convertView;
}
...
public final class ImageTextView{
public ImageView image;
public TextView title;
}
...
public class ImageLoadTask extends AsyncTask<Void, Void, Void> {}
请问怎么更新 imageTextView.image ?
adapter = new ImageAdapter(this);
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
new ImageLoadTask(this, adapter).execute();
有调用,主要是这里怎么实现呢:
@Override
protected Void doInBackground(Void... params) {
for (int i = 0; i < adapter.getCount(); i++) {
...
publishProgress(); // 通知去更新UI
} 展开
map.put("title","title");
map.put("img","imgURL");
...
List<HashMap<String, Object>> list;
private LayoutInflater listContainer;
...
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageTextView imageTextView = null;
if(convertView ==null){
imageTextView = new ImageTextView();
convertView = listContainer.inflate(R.layout.main_img_list, null);
imageTextView.image =(ImageView) convertView.findViewById(R.id.img);
imageTextView.title =(TextView) convertView.findViewById(R.id.title);
convertView.setTag(imageTextView);
}else{
imageTextView = (ImageTextView) convertView.getTag();
}
imageTextView.image.setBackgroundResource(R.drawable.icon);
//此处为默认图片
imageTextView.title.setText((String)list.get(position).get("title"));
this.convertView=convertView;
return convertView;
}
...
public final class ImageTextView{
public ImageView image;
public TextView title;
}
...
public class ImageLoadTask extends AsyncTask<Void, Void, Void> {}
请问怎么更新 imageTextView.image ?
adapter = new ImageAdapter(this);
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
new ImageLoadTask(this, adapter).execute();
有调用,主要是这里怎么实现呢:
@Override
protected Void doInBackground(Void... params) {
for (int i = 0; i < adapter.getCount(); i++) {
...
publishProgress(); // 通知去更新UI
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询