我有一个 arrayaadapter,我在其中检索带有图像的电话联系人号码并将其显示在列表中。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) (getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE));
view = inflater.inflate(renderer, null);
}
TextView text = (TextView) view.findViewById(R.id.name);
TextView textContNo = (TextView) view.findViewById(R.id.contactno);
TextView textEmailId = (TextView) view.findViewById(R.id.emailId);
Profile contact = listCont.get(position);
text.setText(contact.getName());
QuickContactBadge photo = (QuickContactBadge ) view.findViewById(R.id.quickContactBadge1);
photo.setTag(contact.getMobileNo());
new LoadImage(photo).execute(contact.getMobileNo());
并使用 asyncTask 在 backgroundthread 中加载图像
class LoadImage extends AsyncTask<String, Void, Bitmap>{
private QuickContactBadge qcb;
public LoadImage(QuickContactBadge qcb) {
this.qcb= qcb;
}
@Override
protected Bitmap doInBackground( final String... params) {
activity.runOnUiThread(new Runnable() {
public void run() {
new QuickContactHelper(activity, qcb, (String) params[0]).addThumbnail();
}
});
return null;
}
@Override
protected void onPostExecute(Bitmap result) {
}
}
我面临两个问题,图像重复并且滚动不流畅我试图在 getview 方法中实现视图,但不确定如何使用它,或者是否有任何其他方法可以阻止图像重复。任何帮助表示赞赏