1
동적으로, 저는 하나의 질문 아래에서 여러 옵션을 recycleview에 추가했습니다. 이제 사용자는 아래 그림에서 각, 질문에 내 하나의 옵션을 선택할 수 있습니다 recyclerview에서 선택한 라디오 버튼의 값을 가져 오는 방법은 무엇입니까?
Recyclerview Adapter
클래스는, 나는 사용자가 RadioButton
를 선택하는 경우 모두, 각 질문에서 값을 확인하고 싶지
@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);
}
}
RadioGroup
안에 있습니다.
코드를 사용하여 간단히 설명해주십시오. – pb123
안녕하세요. 나는 그때까지 작동하지 않으면 오늘 밤 코드에 대한 답을 줄 수 있습니다. 내 게시물을 편집합니다 – bogdanN
각 질문 (이름 및 ID)에서 옵션을 가져올 수 없습니다. 코드로 날 정교하게 만들어 주시겠습니까? 미리 감사드립니다 !!!! – pb123