@Override public View getView(int position, View convertView, ViewGroup parent) { final ViewItem item; if (convertView == null) { convertView = mInflater.inflate(R.layout.item, null); item = new ViewItem(); // item.productImageView = (ImageView) convertView // .findViewById(R.id.ImageViewItem); // item.productImageView = (ImageView) convertView.findViewById(R.drawable.icon); item.productTitle = (TextView) convertView.findViewById(R.id.TextViewItem); item.productCheckbox = (CheckBox) convertView.findViewById(R.id.CheckBoxSelect); convertView.setTag(item); } else { item = (ViewItem) convertView.getTag(); } Device curProduct = mProductList.get(position); // item.productImageView.setImageDrawable(item.productImageView.getDrawable()); item.productTitle.setText(curProduct.getDeviceName()); if (!mShowCheckbox) { item.productCheckbox.setVisibility(View.GONE); } else { if (curProduct.selected == true) item.productCheckbox.setChecked(true); else item.productCheckbox.setChecked(false); } return convertView; }
/** 데이터를 리스트뷰에 추가 */ public void addItem(int name, String title) { ViewItem item = new ViewItem(); item.textTitle = title; mItemArray.add(item); notifyDataSetChanged(); }