ツイアーフィーダーを使用していますが、viewHolderパターンを使用して画像を管理する方法がわかりません
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.activity_result, null);
holder = new ViewHolder();
holder.name = (TextView) v.findViewById(R.id.name);
holder.tweet = (TextView) v.findViewById(R.id.tweet);
holder.avatar = (ImageView) v.findViewById(R.id.avatar);
Log.v("TAG", "ACA SI LLEGE holder cargado");
holder.name.setText(mitems.get(position).getFromUser());
holder.tweet.setText(mitems.get(position).getText());
task = new BackgroundAsyncTask(this, position);
task.execute();
v.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
return v;
}
public class BackgroundAsyncTask extends AsyncTask<Void, Integer, Void>{
private ResultsAdapter resultAdapter;
private int position;
private MyApplication myapp;
private Bitmap bitmap;
public BackgroundAsyncTask(ResultsAdapter adptr, int position){
this.resultAdapter = adptr;
this.position = position;
}
@Override
protected Void doInBackground(Void... params) {
try {
for(int i = 0; i < mitems.size(); i++){
bitmap = BitmapFactory.decodeStream((InputStream)
new URL(mitems.get(i).getProfileImageUrl()).getContent());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
myapp.setProgreso(values[0]);
}
@Override
protected void onPostExecute(Void result){
holder.avatar.setImageBitmap(bitmap);
}