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 positio
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;
}
change your getView like this if it help you..
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.cat_content, null);
}
name = (TextView) convertView.findViewById(R.id.name);
item = new HashMap<String, String>();
item = data.get(position);
name.setText(item.get(CATEGORY_NAME));
return convertView;
}