In my project I am displaying the checkboxes dynamically. But I want to get the id values of all the checkboxes that are selected. In my application the user will select multiple checkboxes and I need to store those selected checkboxes id’s in an arraylist. How can I get the selected checkboxes id’s?
My Code:
public View getView(int position, View convertView, ViewGroup parent)
{
View view = convertView;
try
{
if (view == null)
{
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.list_item1, null);
}
final UserBO listItem = mList.get(position);
if (listItem != null)
{
Rl = (LinearLayout)findViewById(R.id.chklnlayout);
ArrayList<UserBO> mList1;
CheckBox[] cbs = new CheckBox[20];
for(int k=0; k<list.size(); k++)
{
System.out.println("list in for loop"+list.get(0));
arr = list.get(k);
cbs[k] = new CheckBox(getContext());
Rl.addView(cbs[k]);
cbs[k].setText((CharSequence) arr.get(2));
cbs[k].setTextColor(Color.parseColor("#000000"));
}
}
}
catch(Exception e){
String err = (e.getMessage()==null)?"hii":e.getMessage();
Log.e("sdcard-err2:",err);
}
return view;
}
Please help me regarding this….Thanks in Advance
In your code for loop,
Write this line,
Now
implements OnClickListenerin your activityin
or something like,
And let me know what happen..