Items inside GridView getting repeated when screen scrolls

前端 未结 5 909
日久生厌
日久生厌 2020-12-02 10:41

I\'m using a GridView to show a set of Categories that user can chose. Each item of the grid is consisted by an ImageView and a TextView, both retrieved from server. When an

5条回答
  •  青春惊慌失措
    2020-12-02 11:41

    These is my code for GirdView with Button + Textview

    public View getView(final int position, View convertView, ViewGroup parent) {
            LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.grid_item, null);  
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            TextView text = (TextView)convertView.findViewById(R.id.texto_grid);
            text.setText(app_listaActiva_NOMBRES[position]);
            Button image = (Button)convertView.findViewById(R.id.miniatura_grid);
            image.setBackgroundResource(R.drawable.custom_button);
            image.setOnClickListener(new MyOnClickListener2(position,app_listaActiva_SONIDOS));
            return convertView;
        }
    

提交回复
热议问题