lundi 14 décembre 2015

uncheck all dynamically created checkboxes in android in a layout

I have a method like this: public void initialiseCheckBox(){

    ArrayList<String> list = new ArrayList<String>();
    list.add("Banners");
    list.add("Poster");
    list.add("Stickers");

    for(int i = 0; i < list.size(); i++) {

        checkBox = new CheckBox(getActivity());
        checkBox.setId(i);
        checkBox.setText(list.get(i));

        FlowLayout.LayoutParams params = new FlowLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.rightMargin = 32;
        params.topMargin = 5;

        checkBox.setOnClickListener(getOnClickDoSomething(checkBox));
        linearMain.addView(checkBox, params);
    }

}

I can get all the selected CheckBox via the getOnClickDoSomething(checkBox) now how can I uncheck all the checked CheckBox in a different method am using a fragment. Thank you




Aucun commentaire:

Enregistrer un commentaire