我在recylerview行中有以下内容
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/radioItems"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<RadioButton android:id="@+id/radio_yes"
android:layout_width="wrap_content"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="Yes"/>
<RadioButton android:id="@+id/radio_no"
android:layout_width="wrap_content"
android:layout_weight="1"
android:textSize="12sp"
android:layout_height="wrap_content"
android:text="No"/>
</RadioGroup>
所以我想在我的recyclerview适配器中侦听检查无线电组项并获取是否已检查是或否。因此我在bindviewholder上的recyclerview中有[]
holder.radioItems.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Log.i("test",""+group.getCheckedRadioButtonId()); } });
但是当我检查日志时,可以看到类似
2131230980, 2131230979
的值,但看不到单选按钮的ID
我希望在日志中看到radio_yes
或radio_no
的ID。我在这方面错过了什么。我仍然想使用单选按钮,而不是独立的单选按钮。
我在recylerview行项目中具有以下内容