1

Here's my aproach:

I have a custom ListView containing a custom Adapter containing two different kind of Views. One of them has a CheckBox in each View.

I just want to notify the Activity when one of those CheckBoxes have been clicked, and to pass it a boolean: true if ANY of the boxes are checked, false otherwise.

How should I do it?

I just need the theorethical answer, not code.

Thank you very much.

4

1 回答 1

2

1- implement the activity by checkedChangeListene and override the code in activity

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
    {
        if ( isChecked )
        {

               Object obj = buttonView.getTag();
            // perform logic
        }

    }

2- pass the activity in custom adapter constructor.

3- set in getView

   CheckBox  chkBx = (CheckBox ) findViewById( R.id.repeat_checkbox );
    if(null!=chkBx ){
    chkBx.setOnCheckedChangeListener(mActivty);
    chkBx.setTag(position);
   }
于 2012-06-08T08:04:22.807 回答