Position of listitem items changes on scrolling

后端 未结 2 1870
余生分开走
余生分开走 2021-01-25 15:48

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

2条回答
  •  情深已故
    2021-01-25 16:45

    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();
         item = data.get(position);
         name.setText(item.get(CATEGORY_NAME));
    
        return convertView;
    }
    

提交回复
热议问题