5 개 섹션 (각 섹션은 목록의 항목 임)이있는 PullToRefresh ListView가 있으며 각 섹션에는 여러 개의 사진이 있습니다. 5 개의 섹션을 섹션 사진으로 채우는 BaseAdapter 클래스가 있습니다. 문제는 목록보기를 처음로드 할 때 사진이 올바르게 표시되지 않지만 스크롤 할 때 사진이 올바른 위치에 나타날 때입니다. 사진을로드 할 때 BitmapFun 코드를 사용합니다.BaseAdapter의 이미지 위치가 맞지 않습니다.
제가 가지고
private ArrayList<Pair<Integer, ArrayList<String>>> section_photos_url;
제 값은 부이고, 두 번째는 각 섹션의 사진 배열이다.
의 getView 방법 :
public View getView(int position, View convertView, ViewGroup container) {
if (position < 5) {
ItemViewHolder viewHolder;
// Si la vista de dicha posicion ha sido inflada
if (view_array[position] == null) {
// Inflate the view
LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
switch (section_photos_url.get(position).first) {
case ConstantsTypeSection.SECTION1:
view_array[position] = li.inflate(R.layout.timeline_section_today_trending, container, false);
break;
case ConstantsTypeSection.SECTION2:
view_array[position] = li.inflate(R.layout.timeline_section_trendy_smiler, container, false);
break;
case ConstantsTypeSection.SECTION3:
view_array[position] = li.inflate(R.layout.timeline_section_around_me, container, false);
break;
case ConstantsTypeSection.SECTION4:
view_array[position] = li.inflate(R.layout.timeline_section_trending_hashtag, container, false);
break;
case ConstantsTypeSection.SECTION5:
view_array[position] = li.inflate(R.layout.timeline_section_last_content, container, false);
break;
}
viewHolder = new ItemViewHolder();
viewHolder.sectionName = (TextView) view_array[position].findViewById(R.id.section_name);
viewHolder.userName = (TextView) view_array[position].findViewById(R.id.user_name);
viewHolder.hashTag = (TextView) view_array[position].findViewById(R.id.hash_tag_name);
viewHolder.userImage = (ImageView) view_array[position].findViewById(R.id.user_photo);
viewHolder.item1 = (RecyclingImageView) view_array[position].findViewById(R.id.item_1);
viewHolder.item2 = (RecyclingImageView) view_array[position].findViewById(R.id.item_2);
viewHolder.item3 = (RecyclingImageView) view_array[position].findViewById(R.id.item_3);
viewHolder.item4 = (RecyclingImageView) view_array[position].findViewById(R.id.item_4);
viewHolder.item5 = (RecyclingImageView) view_array[position].findViewById(R.id.item_5);
viewHolder.item6 = (RecyclingImageView) view_array[position].findViewById(R.id.item_6);
viewHolder.item7 = (RecyclingImageView) view_array[position].findViewById(R.id.item_7);
viewHolder.photos_layout = (LinearLayout) view_array[position].findViewById(R.id.photo_section);
view_array[position].setTag(viewHolder);
} else {
viewHolder = (ItemViewHolder) view_array[position].getTag();
}
switch (section_photos_url.get(position).first) {
case ConstantsTypeSection.SECTION1:
viewHolder.sectionName.setText(context.getResources().getString(R.string.today_trending_section));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.photos_layout.addView(getPhotoView(section_photos_url.get(0).second), lp);
break;
case ConstantsTypeSection.SECTION2:
viewHolder.sectionName.setText(context.getResources().getString(R.string.trendy_smiler_section));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.photos_layout.addView(getPhotoView(section_photos_url.get(1).second), lp);
break;
case ConstantsTypeSection.SECTION3:
viewHolder.sectionName.setText(context.getResources().getString(R.string.around_me_section));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.photos_layout.addView(getPhotoView(section_photos_url.get(2).second), lp);
break;
case ConstantsTypeSection.SECTION4:
viewHolder.sectionName.setText(context.getResources().getString(R.string.trending_hashtag_section));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.photos_layout.addView(getPhotoView(section_photos_url.get(3).second), lp);
break;
case ConstantsTypeSection.SECTION5:
viewHolder.sectionName.setText(context.getResources().getString(R.string.last_content_section));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.photos_layout.addView(getPhotoView(section_photos_url.get(0).second), lp);
break;
}
return view_array[position];
} else {
return null;
}
}
private class ItemViewHolder {
TextView sectionName;
TextView userName;
TextView hashTag;
ImageView userImage;
RecyclingImageView item1;
RecyclingImageView item2;
RecyclingImageView item3;
RecyclingImageView item4;
RecyclingImageView item5;
RecyclingImageView item6;
RecyclingImageView item7;
LinearLayout photos_layout;
}
private View getPhotoView(ArrayList<String> photos) {
View view = null;
LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
switch (photos.size()) {
case 1:
break;
case 3:
view = li.inflate(R.layout.timeline_item_three, null, false);
break;
case 5:
if (Math.random() * 2 < 1) {
view = li.inflate(R.layout.timeline_item_three_two, null, false);
} else {
view = li.inflate(R.layout.timeline_item_two_three, null, false);
}
break;
case 7:
default:
view = li.inflate(R.layout.timeline_item_seven, null, false);
break;
}
RecyclingImageView image = null;
for (int i = 0; i < photos.size(); i++) {
switch (i) {
case 0:
image = (RecyclingImageView) view.findViewById(R.id.item_1);
break;
case 1:
image = (RecyclingImageView) view.findViewById(R.id.item_2);
break;
case 2:
image = (RecyclingImageView) view.findViewById(R.id.item_3);
break;
case 3:
image = (RecyclingImageView) view.findViewById(R.id.item_4);
break;
case 4:
image = (RecyclingImageView) view.findViewById(R.id.item_5);
break;
case 5:
image = (RecyclingImageView) view.findViewById(R.id.item_6);
break;
case 6:
image = (RecyclingImageView) view.findViewById(R.id.item_7);
break;
}
CacheLoaderImagesSingleton.getInstance().getImageFetcher().loadImage(photos.get(i), image);
}
return view;
}
어떤 제안이 이미지를 제대로 보여? 그것들은 이미지들입니다. 모든 사진이 보라색 꽃 사진이어야하고 노란색이 아니기 때문에 첫 번째 사진은 잘못된 이미지입니다. 두 번째 것은 정확합니다. 이미지는
당신이 어떻게 잘못 방법이 제대로 보여주고있다 중 하나 보이고있다에 대한 예제를 제공시겠습니까? – Neil