的列表项项目的立场上滚动变化 [英] Position of listitem items changes on scrolling
问题描述
我有以下code,其中我做的JSON解析和显示结果列表视图。 我面临的问题是每当我滚动列表视图列表视图我的内容位置获得前变化。如果住宿是在列表中第一个项目,当我向下滚动我可以再次看到住宿,在列表中或在任何其他位置上的最后一个项目。我的日志猫显示了正确的结果,但不是列表视图。我没有得到我哪里错了,为什么我的列表没有显示我正确的结果。
I have following code in which i am doing JSON parsing and showing results in listview. The problem i am facing is whenever i am scroll the listview my listview contents position get changes for ex. if Accommodation is at 1st item in list, when i scroll down i can see accommodation again as a last item in the list or at any other position. My log-cat showing the proper result but not the listview. I am not getting where i went wrong why my list not showing me proper result.
推荐答案
尝试按照viewHolder模式如下
Try to follow viewHolder pattern as below
ViewHolder holder;
if(convertView == null)
{
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.cat_content, null);
holder.name = (ImageView)convertView.findViewById(R.id.name);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
item = new HashMap<String, String>();
item = data.get(position);
holder.name.setText(item.get(CATEGORY_NAME));
return convertView;
class ViewHolder
{
TextView name;
}
这篇关于的列表项项目的立场上滚动变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!