private
class
CustomListViewAdapter
extends
ArrayAdapter<SampleData> {
private
ArrayList<Integer>listItem;
int
resource;
public
CustomListViewAdapter(Context context,
int
resource, List<SampleData> objects) {
super
(context, resource, objects);
this
.resource = resource;
}
@Override
public
View getView(
int
position, View converView, ViewGroup parent) {
View itemView = converView;
if
(itemView ==
null
) {
LayoutInflater li = getLayoutInflater();
itemView = li.inflate(
this
.resource,
null
);
}
final
SampleData item = getItem(position);
if
(item !=
null
) {
TextView textView = (TextView) itemView.findViewById(R.id.main_tv);
TextView textView2 = (TextView) itemView.findViewById(R.id.sub_tv);
CheckBox checkBox = (CheckBox)itemView.findViewById(R.id.checkbox1);
textView.setText(item.getMainText());
checkBox.setChecked(((ListView)parent).isItemChecked(position));
checkBox.setFocusable(
false
);
checkBox.setClickable(
false
);
checkBox.setOnCheckedChangeListener(
new
CompoundButton.OnCheckedChangeListener() {
@Override
public
void
onCheckedChanged(CompoundButton buttonView,
boolean
isChecked) {
item.setCheck(isChecked);
}
});
checkBox.setChecked(item.isCheck());
}
return
itemView;
}
}