2

I use a CheckBox in ListView. My adapter as below:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewTag viewTag;
if(convertView == null) {
convertView = myInflater.inflate(R.layout.row, null);
viewTag = new ViewTag((CheckBox)convertView.findViewById(R.id.row_check));
convertView.setTag(viewTag);
}
else {
viewTag = (ViewTag) convertView.getTag();
}
}
class ViewTag {
CheckBox cbx;
public ViewTag(CheckBox cb) {
this.cbx = cb;
}
}

First: In ListActivity, I try to click a button to set all items checked. How to do it? Second: In ListActivity, how to get the items which were checked?

1
  • Checkout this thread. Commented Jan 5, 2012 at 6:58

3 Answers 3

4

There are many approaches to achieve this, simplest method is create a boolean array to keep state of each row, and set state of check from this array. To get all checked items simply check the same array item value.

Sign up to request clarification or add additional context in comments.

Comments

2

Many ways to get solution to your problem. Please check this tutorial given below, it will provide more information to get solution to your problem.

ListView Example 3 – Simple Multiple Selection Checkboxes

I hope it may help you.

Comments

1

Check this. This tutorial works for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.