안녕하세요. 검색 한 결과 최선을 다했지만 작동하도록 만들지 못했습니다. 목록보기가있어 이미지가있는 휴대 전화 연락처로로드됩니다. 아래에있는 내 코드는Android : Listview 문제 - 이미지가 잘못 할당되었습니다.
public ProfileAdapter(Activity activity, int textViewResourceId, List<Profile> listCont,int renderer, String profileType) {
super(activity, textViewResourceId, listCont);
this.renderer = renderer;
this.listCont = listCont;
this.activity = activity;
this.profileType = profileType;
}
public class ViewHolder {
View rowView;
public TextView textEmailId= null;
public TextView textContNo= null;
public TextView text= null;
public ImageView photo= null;
public int position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//View view = convertView;
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(renderer, null);
holder = new ViewHolder(convertView);
holder.text = (TextView) convertView.findViewById(R.id.name);
holder.textContNo = (TextView) convertView.findViewById(R.id.contactno);
holder.textEmailId = (TextView) convertView.findViewById(R.id.emailId);
holder.photo = (ImageView) convertView.findViewById(R.id.quickContactBadge1);
convertView.setTag(holder);
}
else {
holder =(ViewHolder) convertView.getTag();
holder.position = position;
Profile contact = listCont.get(position);
holder.text.setText(contact.getName());
ImageView photo = (ImageView) convertView.findViewById(R.id.quickContactBadge1);
photo.setTag(contact.getMobileNo());
photo.setImageResource(R.drawable.stub_image);
new LoadImage(photo).execute(contact.getMobileNo());
}
return convertView;
}
class LoadImage extends AsyncTask<String, Void, Bitmap>{
// private final WeakReference<ImageView> viewReference;
private ImageView img;
public LoadImage(ImageView img) {
//viewReference = new WeakReference<ImageView>(view);
this.img=img;
}
@Override
protected Bitmap doInBackground(final String... params) {
new QuickContactHelper(activity, img, (String) params[0]).addThumbnail();
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
// nothing
}
}
문제가 내가 스크롤을 시작할 때 이미지 만 스크롤 한 후, 나는 목록을 얻고 있지만, 이미지가로드입니다 잘못하고 어디 스피 확인 안정과 오른쪽 position..not에 , 나는 목록로드 후 이미지를로드해야하고 이미지가 올바른 위치에 있어야합니다 ... 어떤 도움을 주신다면
대답을 자세히 설명해 주실 수 있습니다 ... 빈 이미지 또는 원래 연락처 이미지를 지정 하시겠습니까? – teekib
아니, 그냥 해봐. if 문에있는 코드는 무언가를 지정해야합니다. 내 대답을 편집 할게. – Heinrisch