1
動態地,我在recycleview的一個問題下添加了多個選項。現在,用戶可以選擇在下面的圖像的每個questions.Look內的一個選項, 如何在回收站查看所選單選按鈕的值?
Recyclerview Adapter
類,
@Override
public void onBindViewHolder(final MyViewHolder holder,int position) {
final PollQstWithAns poll = dataList.get(position);
holder.txt_poll_question.setText(poll.getPollQstName());
for (int i = 0; i < poll.getOptionList().size(); i++) {
final PollsData mPollsOptionsList = poll.getOptionList().get(i);
final RadioButton rb = new RadioButton(context);
rb.setText(mPollsOptionsList.getAns1());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ColorStateList colorStateList = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled}
},
new int[]{
Color.DKGRAY
, ContextCompat.getColor(context, R.color.colorPrimary)
}
);
rb.setButtonTintList(colorStateList);
rb.invalidate();
rb.setTextColor(ContextCompat.getColor(context, R.color.gray));
}
holder.optionRadioGroup.addView(rb);
}
}
我想所有從每個問題檢查值,如果用戶選擇RadioButton
裏面的RadioGroup
。
可以請您使用代碼簡單解釋一下嗎? – pb123
嘿。如果到那時你還沒有得到它,我可以在今晚給你一個代碼的答案。我將編輯我的文章 – bogdanN
我無法獲得每個問題(姓名和ID)下的選項。你能用代碼來詳細說明我嗎?提前致謝!!!! – pb123