How to determine which row button the list view button is clicked on

Hello I have listview

one in which I am using a custom adapter and string layout. I like the imageview

top and the bottom has one checkbox on the left and a button on the right end.

Now I want to apply a test listener to checkbox

and push the listener to button

. This is what I do

mybutton.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
       // TODO Auto-generated method stub

   }
});

satView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
   @Override
   public void onCheckedChanged(RadioGroup group, int checkedId) {
       if (isChecked){
           // perform logic
       }
   }
});

      

Question

Thus, the list will be checkbox

, and buttton

in each row. How do I know if the user clicks on the second or third line, etc. checkbox

or button

.

Thanks in advance.

+3


source to share


1 answer


There are several ways to do this. My prefferred method is to add setOnCheckedChangeListener

to your owner checkbox's

to your custom view class in the method getView

.



You can use the parameter position

in getView

to get the current line position.

+2


source







All Articles