i have listview with checkboxes and \"save\" button.
Whichever checkboxes i check and click save button, i want to save the data related to those checked rows into datab
Hi in the GetCardDetails()
method add sr1.setSelected(true)
or sr1.setSelected(false)
in adapter add the following
public static ArrayList itemChecked1 = null;
public CardDetailsAdapter( Context context, ArrayList results) {
super( context, R.layout.welcomelistview, R.id.BankNameID, results );
searchArrayList = results;
getContext = context;
mInflater = LayoutInflater.from(context) ;
itemChecked1 = new ArrayList();
for (int i = 0; i < results.size(); i++) {
itemChecked1.add(i, results.get(i).isSelected()); // initializes all items value with false
}
}
in getview
holder.chkbox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
CardDetails planet = (CardDetails) cb.getTag();
//planet.setSelected(cb.isChecked());
if (holder.chkbox.isChecked()) {
itemChecked1.set(position, true);
holder.chkbox.setChecked(true);
planet.setSelected(true);
} else if (!holder.chkbox.isChecked()) {
itemChecked1.set(position, false);
holder.chkbox.setChecked(false);
planet.setSelected(false);
}
}
});