Aleena
Aleena

Reputation: 273

Get ListItem id/position while clicking on RadioButton in that ListItem.

I have 3 RadioButtons along with some texts in my ListItem using CursorAdapter. I need to get the view (ListItem) position when i click any of the RadioButton in that ListItem. Because , clicking on the RadioButton does not mean that i am Clicking on the ListItem.

Upvotes: 1

Views: 87

Answers (1)

semsamot
semsamot

Reputation: 805

In bindView or newView:

RadioButton radioButton = (RadioButton) view.findViewById(R.id.radio_button_id);
radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
        Log.d(TAG, cursor.getPosition());
    }
});

Also make sure cursor declared as final in method parameters.

Upvotes: 1

Related Questions