public
class
ListString {
String _title;
boolean
_check =
false
;
public
ListString(String title,
boolean
check) {
this
._title = title;
this
._check = check;
}
public
String getTitle() {
return
_title;
}
public
void
setTitle(String title) {
this
._title = title;
}
public
boolean
ismCheck() {
return
_check;
}
public
void
setmCheck(
boolean
check) {
this
._check = check;
}
}
=====================================
public
class
ListViewAdapter
extends
BaseAdapter{
private
Context _context;
private
List<ListString> _itemList;
private
int
_layout;
ViewHolder holder;
private
boolean
checking;
public
ListViewAdapter(Context context,
int
layout, List<ListString> itemList){
this
._context = context;
this
._layout = layout;
this
._itemList = itemList;
}
@Override
public
int
getCount() {
return
_itemList.size();
}
@Override
public
Object getItem(
int
position) {
return
_itemList.get(position);
}
@Override
public
long
getItemId(
int
position) {
return
_itemList.indexOf(getItem(position));
}
@Override
public
View getView(
int
position, View convertView, ViewGroup parent) {
LayoutInflater vi = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if
(convertView ==
null
){
convertView = vi.inflate(_layout,
null
);
holder =
new
ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.code);
holder.chb = (CheckBox) convertView.findViewById(R.id.checkBox1);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
ListString rowItem = (ListString) getItem(position);
holder.title.setText(rowItem.getTitle());
holder.chb.setText(
null
);
holder.chb.setChecked(
false
);
holder.chb.setChecked(rowItem.ismCheck());
return
convertView;
}
}