ListView显示错误(双)数据

时间:2016-04-14 19:58:07

标签: android listview

日志显示为来自API的响应:

{"result":{"list":[
    {"id":"8","name":"Girl","last_name":"","username":"girl1_firstname girl1_lastname","photo":"http:\/\/new.mmm.com\/wp-content\/uploads\/dsp_media\/user_photos\/user_8\/thumbs\/thumb_8_girl3.jpg"},
    {"id":"9","name":"","last_name":"","username":"girl2_firstname girl2_lastname","photo":"http:\/\/new.mmm.com\/wp-content\/uploads\/dsp_media\/user_photos\/user_9\/thumbs\/thumb_9_girl2.jpg"},
    {"id":"92","name":"Artem","last_name":"Bogomaz","username":"artem_bogomaz","photo":"http:\/\/new.mmm.com\/wp-content\/uploads\/dsp_media\/user_photos\/user_92\/thumbs\/thumb_92_IMG_7350.jpg"},
    {"id":"215","name":"Rafal","last_name":"Sob","username":"rafal","photo":"http:\/\/new.mmm.com\/wp-content\/plugins\/dsp_dating\/images\/female-generic.jpg"},
    {"id":"218","name":"rafal","last_name":"Sokk","username":"rafalek2","photo":"http:\/\/new.mmm.com\/wp-content\/plugins\/dsp_dating\/images\/female-generic.jpg"},
    {"id":"220","name":"Rafal","last_name":"Sokk","username":"rafalek3","photo":"http:\/\/new.mmm.com\/wp-content\/plugins\/dsp_dating\/images\/male-generic.jpg"},
    {"id":"221","name":"Rafal","last_name":"Sokk","username":"rafalek4","photo":"http:\/\/new.mmm.com\/wp-content\/plugins\/dsp_dating\/images\/female-generic.jpg"},
    {"id":"281","name":"Bdbdhd","last_name":"Sjhsjdjd","username":"Andrzej12","photo":"http:\/\/new.mmm.com\/wp-content\/plugins\/dsp_dating\/images\/male-generic.jpg"}    
]}}

但是在我的ListView中,我看到双girl1_firstname girl1_lastname而不是Andrzej12,为什么?

当我从API重新加载数据时,我会在最后一个位置更正Andrzej12,接下来几次我在Andrzej12看到了ListView,但有时它仍会显示girl1_firstname girl1_lastname。 ..来自API的数据响应始终显示与Andrzej12相同的数据,为什么不是这样我得到了其他记录?!

适配器中的代码如下:

if (convertView == null) {
    LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.connections_list_view_single, parent, false);

//rest of the code
}

rest of the code应位于括号内。

0 个答案:

没有答案