How To Get The The Multiple Checkbox Values Using Custom Adapter In Android
Hi In the below code I am display textview with checkboxes.Now When I am selecting single value it's returning the name of the textview same as second textview name also. Now I wan
Solution 1:
Declare and Initialize this in your adapter...
ArrayList<String> checkedFriends = newArrayList<String>();
Replace your click listner with this....
holder.check1.setOnCheckedChangeListener(newOnCheckedChangeListener(){
publicvoidonCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkBoxState[position]=isChecked;
if(isChecked){
checkedFriends.add(friend[position].userName);
check=friend[position].userName;
} else {
checkedFriends.remove(friend[position].userName);
}
Toast.makeText(getApplicationContext(),checkedFriends.toString()+" checked", Toast.LENGTH_LONG).show();
}
});
Post a Comment for "How To Get The The Multiple Checkbox Values Using Custom Adapter In Android"