0
我有一個來自twitter的數據的列表視圖。我想展示twits,但它顯示了每個twit項目中的用戶。所以我想爲其他用戶顯示默認圖片。我的代碼正在工作,但是當我移動listview時,用戶配置文件圖像再次爲每個用戶提供。如果它是轉推,我可以如何解決?代碼「rt」。android listview移動變化
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (null != pDialog && pDialog.isShowing()) {
pDialog.dismiss();
}
if (null == result || result.length() == 0) {
showToast("Bağlantı yok");
Twitter.this.finish();
} else {
List<String> galleryImages = new ArrayList<String>();
try { JSONObject jsonObject = new JSONObject(result);
veriArray = jsonObject.getJSONArray("results");
int nVeri = veriArray.length();
for (int i = 0; i < nVeri; i++) {
JSONObject veriObject = veriArray.getJSONObject(i);
baslik = veriObject.getString("text");
kImaj = veriObject.getString("profile_image_url");
kisaAciklama = veriObject.getString("from_user_name");
Item objItem = new Item();
rt=baslik.substring(0, 2);
if(rt.equals(kiyas)){
kImaj="";
objItem.setLink(kImaj);
objItem.setName(baslik);}
else {
objItem.setLink(kImaj);
objItem.setName(baslik);
}
arrayOfList.add(objItem);
//objItem.setLink(link);
}
} catch (JSONException e)
{ e.printStackTrace(); } }
Collections.sort(arrayOfList, new Comparator<Item>() {
public int compare(Item lhs, Item rhs) {
return (lhs.getAge() - rhs.getAge());
}
});
setAdapterToListview();
}
}
我的適配器
public class KampanyaRowAdapter extends ArrayAdapter<Item> {
private Activity activity;
private List<Item> items;
private Item objBean;
private int twitterrow;
private ImageLoader imageLoader;
public KampanyaRowAdapter(Activity act, int resource, List<Item> arrayList) {
super(act, resource, arrayList);
this.activity = act;
this.twitterrow = resource;
this.items = arrayList;
imageLoader = new ImageLoader(act);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(twitterrow, null);
holder = new ViewHolder();
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
if ((items == null) || ((position + 1) > items.size()))
return view;
objBean = items.get(position);
holder.tvName = (TextView) view.findViewById(R.id.tvname);
holder.tvCity = (TextView) view.findViewById(R.id.tvcity);
holder.imgView = (ImageView) view.findViewById(R.id.image);
if (holder.tvName != null && null != objBean.getName()
&& objBean.getName().trim().length() > 0) {
holder.tvName.setText(Html.fromHtml(objBean.getName()));
}
if (holder.tvCity != null && null != objBean.getCity()
&& objBean.getCity().trim().length() > 0) {
holder.tvCity.setText(Html.fromHtml(objBean.getCity()));
}
if (holder.imgView != null) {
if (null != objBean.getLink()
&& objBean.getLink().trim().length() > 0) {
imageLoader.DisplayImage(objBean.getLink(), activity,
holder.imgView);
} else {
}
}
return view;
}
public class ViewHolder {
public TextView tvName, tvCity, tvBDate, tvGender, tvAge;
private ImageView imgView;
}
}
在服務器的listview中使用延遲加載圖像。 http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview去爲此 –
有無論如何鎖定列表視圖後,我解析。? – slhgndz