我的 ListItem
中有 3 个 RadioButtons
以及一些使用 CursorAdapter
的文本。当我单击 ListItem
中的任何 RadioButton
时,我需要获取 View (ListItem) 位置。因为,单击 RadioButton
并不意味着我正在单击 ListItem。
最佳答案
在 bindView 或 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());
}
});
还要确保游标在方法参数中声明为 final。
关于android - 单击该 ListItem 中的 RadioButton 时获取 ListItem id/位置。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25203964/