나는 ListView
을 가지고 있으며 하단에는 더 많은 버튼이로드되어 있습니다. 로드 추가 버튼을 클릭하면 원격에서 목록 어댑터 데이터 세트를 추가하는 데이터를 추가합니다. 모든 목록 항목에는로드 할 ImageLoader가 큰 사진을 사용합니다. 어댑터 notifyDataSetChanged
을 사용하면 모든 항목이 getView가되고 모든 항목이 다시 그려지며 큰 사진이 다시 그려지고 UI 새로 고침이 느껴집니다. 새 추가 항목이 변경되었다는 알림을 보내고 새 항목 만 다시로드 하시겠습니까? 이 같은Android ListView 항목 추가 기능이 notifyDataSetChanged를 사용하지 않는 방법은 무엇입니까?
내 어댑터 :
public class PhotoSquareAdapter extends BaseAdapter
{
private List<PhotoRecom> data;
public PhotoSquareAdapter(List<PhotoRecom> data)
{
this.data = data;
}
public void addList(List<PhotoRecom> d) {
for (PhotoRecom n : d) {
data.add(n);
//addView(data.size() - 1);
}
super.notifyDataSetChanged();
}
@Override
public int getCount() {
return data.size();
}
@Override
public PhotoRecom getItem(int position) {
if (position >= getCount())
return data.get(getCount() - 1);
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final PhotoRecom item = getItem(position);
final ViewHolder holder;
if (convertView == null) {
LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = li.inflate(R.layout.photo_square_list_item, parent, false);
holder = new ViewHolder();
holder.iv_photo_square_listitem_head_thumbnail = (ImageView) convertView.findViewById(R.id.iv_photo_square_listitem_head_thumbnail);
holder.iv_photo_square_city = (ImageView) convertView.findViewById(R.id.iv_photo_square_city);
holder.tv_photo_square_nick = (TextView) convertView.findViewById(R.id.tv_photo_square_nick);
holder.tv_photo_square_title = (TextView) convertView.findViewById(R.id.tv_photo_square_title);
holder.tv_photo_square_like = (TextView) convertView.findViewById(R.id.tv_photo_square_like);
holder.iv_photo_square_photo = (ImageView) convertView.findViewById(R.id.iv_photo_square_photo);
holder.tv_photo_square_saw = (TextView) convertView.findViewById(R.id.tv_photo_square_saw);
holder.tv_photo_square_chat = (TextView) convertView.findViewById(R.id.tv_photo_square_chat);
holder.pb_loading_img = (ProgressBar) convertView.findViewById(R.id.pb_loading_img);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
imageLoader.displayImage((url + item.getPhoto()), holder.iv_photo_square_photo, options);
//...
return convertView;
}
private class ViewHolder {
ImageView iv_photo_square_listitem_head_thumbnail;
ImageView iv_photo_square_city;
TextView tv_photo_square_nick;
ProgressBar pb_loading_img;
TextView tv_photo_square_title;
TextView tv_photo_square_like;
ImageView iv_photo_square_photo;
TextView tv_photo_square_saw;
TextView tv_photo_square_chat;
}
}
이 점에서 네일 홈 지점은 목록 항목보기가로드 될 때마다 이미지로드를 호출 할 필요가 없어야한다는 것입니다. 그것은 장치에 대해 지루한 작업입니다. 데이터를 일시적으로 캐시하는 방법에는 여러 가지가 있습니다. – zgc7009