Java Code Examples for android.widget.RadioButton#setOnCheckedChangeListener()

The following examples show how to use android.widget.RadioButton#setOnCheckedChangeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ARadioGroup.java    From Stylish-Widget-for-Android with Apache License 2.0 6 votes vote down vote up
private void search(Context context, View view) {
    if (view instanceof RadioButton) {
        final RadioButton radioButton = (RadioButton) view;
        radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    clearCheck(radioButton);
                    selected = radioButton;
                    if (trigger)
                        listener.onCheckedChanged(ARadioGroup.this, buttonView.getId());
                }
            }
        });
        radioButtons.add(radioButton);
    } else if (view instanceof ViewGroup) {
        search(context, (ViewGroup) view);
    }
}
 
Example 2
Source File: ReportBugFragment.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater,
                final ViewGroup container, final Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setActionBarTitle(R.string.Report_fragment_title);
    final View view = inflater.inflate(R.layout.fragment_report_bug, null);
    mReportedBugTextView = (EditText) view
                    .findViewById(R.id.text_bug_description);
    mDeviceInfoTextView=(EditText)view.findViewById(R.id.text_device_description);
    mReportBugSelect = (RadioButton) view
                    .findViewById(R.id.radio_reportbug);
    mReportSuggestionSelect = (RadioButton) view
                    .findViewById(R.id.radio_suggestfeature);
    
    mReportSuggestionSelect.setOnCheckedChangeListener(this);
    mReportSuggestionSelect.setChecked(true);
    mReportBugButton = (Button) view.findViewById(R.id.button_report_bug);
    mReportBugButton.setOnClickListener(this);
    return view;
}
 
Example 3
Source File: BackupActivity.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
private RadioButton makeRadioButton(RadioGroup baks, final String bk, final boolean item) {
    RadioButton bkb = new RadioButton(this);
    bkb.setText(bk);


    bkb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                selectedBackup = bk;
                selected = item;
                Log.d("backuppage", "selected = " + selectedBackup);
                backupSelected(selected);
            }
        }
    });

    baks.addView(bkb);
    return bkb;
}
 
Example 4
Source File: BindingAdapters.java    From Flubber with Apache License 2.0 6 votes vote down vote up
@BindingAdapter({"checked", "model"})
public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) {

    if (checked == null) {
        return;
    }

    radioButton.setOnCheckedChangeListener(
            (buttonView, isChecked) -> {
                if ((checked.get() == null || !checked.get().equals(model))
                        && isChecked) {

                    checked.set(model);
                }
            });

    final T checkedModel = checked.get();
    final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model);

    if (shouldBeChecked != radioButton.isChecked()) {
        radioButton.setChecked(shouldBeChecked);
    }
}
 
Example 5
Source File: RecyclerViewScrollActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
private void initTab() {
    int padding = Tools.dip2px(this, 10);
    for (int i = 0; i < 20; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setPadding(padding, 0, padding, 0);
        rb.setButtonDrawable(null);
        rb.setGravity(Gravity.CENTER);
        rb.setTag(i * 5);
        rb.setText("Group " + i);
        rb.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        try {
            rb.setTextColor(getResources().getColorStateList(R.color.bg_tab_text));
        } catch (Exception e) {
            e.printStackTrace();
        }
        rb.setCompoundDrawablesWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.bg_block_tab));
        rb.setOnCheckedChangeListener(onCheckedChangeListener);
        rg_tab.addView(rb);
    }
    ((RadioButton) rg_tab.getChildAt(0)).setChecked(true);
}
 
Example 6
Source File: ExpandableActivity.java    From OmegaRecyclerView with MIT License 5 votes vote down vote up
protected void setupRadioButtons() {
    RadioButton dropdownRadioButton = findViewById(R.id.radiobutton_dropdown);
    RadioButton fadeRadioButton = findViewById(R.id.radiobutton_fade);
    RadioButton singleRadioButton = findViewById(R.id.radiobutton_single);
    RadioButton multipleRadioButton = findViewById(R.id.radiobutton_multiple);

    switch (mRecyclerView.getChildExpandAnimation()) {
        case OmegaExpandableRecyclerView.CHILD_ANIM_DROPDOWN:
            dropdownRadioButton.setChecked(true);
            break;
        case OmegaExpandableRecyclerView.CHILD_ANIM_FADE:
            fadeRadioButton.setChecked(true);
            break;
    }

    switch (mRecyclerView.getChildExpandAnimation()) {
        case OmegaExpandableRecyclerView.CHILD_ANIM_DROPDOWN:
            dropdownRadioButton.setChecked(true);
            break;
        case OmegaExpandableRecyclerView.CHILD_ANIM_FADE:
            fadeRadioButton.setChecked(true);
            break;
    }

    dropdownRadioButton.setOnCheckedChangeListener(this);
    fadeRadioButton.setOnCheckedChangeListener(this);
    singleRadioButton.setOnCheckedChangeListener(this);
    multipleRadioButton.setOnCheckedChangeListener(this);
}
 
Example 7
Source File: WidgetConfigureActivity.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    final Bundle extras = intent.getExtras();
    if (extras != null) {
        setContentView(R.layout.widget_config);
        setFinishOnTouchOutside(true);

        RadioButton stepsButton = (RadioButton) findViewById(R.id.stepsRadioButton);
        RadioButton distanceButton = (RadioButton) findViewById(R.id.distanceRadioButton);
        RadioButton caloriesButton = (RadioButton) findViewById(R.id.caloriesRadioButton);
        Button saveButton = (Button) findViewById(R.id.save);
        stepsButton.setOnCheckedChangeListener(this);
        distanceButton.setOnCheckedChangeListener(this);
        caloriesButton.setOnCheckedChangeListener(this);
        saveButton.setOnClickListener(this);

        widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);

        final Intent resultValue = new Intent();
        resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
        setResult(RESULT_OK, resultValue);
    } else {
        finish();
    }
}
 
Example 8
Source File: LanguageFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.intro_language, container, false);
    RadioGroup radioGroup = v.findViewById(R.id.radioGroup);
    
    List<LocaleUtils.Translation> langs = LocaleUtils.getSupportedLanguages(getActivity());
    String currentLang = Preferences.LANGUAGE.get();
    int pos = 0;
    for (int i = 0; i < langs.size(); i++) {
        LocaleUtils.Translation lang = langs.get(i);
        if (lang.getLanguage().equals(currentLang))
            pos = i + 1;
        RadioButton button = new RadioButton(getContext());
        button.setTag(lang.getLanguage());
        button.setText(lang.getDisplayText());
        button.setTextColor(getResources().getColor(R.color.white));
        button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        int padding = (int) (button.getTextSize() / 2);
        button.setPadding(padding, padding, padding, padding);
        button.setOnCheckedChangeListener(this);
        radioGroup.addView(button);
    }
    if (pos != 0)
        ((RadioButton) radioGroup.getChildAt(pos)).setChecked(true);
    return v;
}
 
Example 9
Source File: RadioButtonGroupHelper.java    From AndroidProject with Apache License 2.0 5 votes vote down vote up
public RadioButtonGroupHelper(RadioButton... groups) {
    mViewSet = new ArrayList<>(groups.length - 1);

    for (RadioButton view : groups) {
        // 如果这个RadioButton没有设置id的话
        if (view.getId() == View.NO_ID) {
            throw new IllegalArgumentException("are you ok?");
        }
        view.setOnCheckedChangeListener(this);
        mViewSet.add(view);
    }
}
 
Example 10
Source File: XmRadioGroup.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void onChildViewRemoved(View parent, View child) {
	if (parent == XmRadioGroup.this && child instanceof RadioButton) {
		((RadioButton) child).setOnCheckedChangeListener(null);
	} else if (parent == XmRadioGroup.this
			&& child instanceof ViewGroup) {
		RadioButton btn = findRadioButton((ViewGroup) child);
		if (btn != null)
			btn.setOnCheckedChangeListener(null);
	}

	if (mOnHierarchyChangeListener != null) {
		mOnHierarchyChangeListener.onChildViewRemoved(parent, child);
	}
}
 
Example 11
Source File: FaBoPinRadioGroupFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * ピンを選択するためのRadioButtonを作成します.
 * @param inflater インフレータ
 * @param pin ピン
 * @return RadioButtonのインスタンス
 */
private RadioButton createRadioButton(final LayoutInflater inflater,final FaBoShield.Pin pin) {
    RadioButton radio = (RadioButton) inflater.inflate(R.layout.item_fabo_radio_button_pin, null, false);
    radio.setText(pin.getPinNames()[1]);
    radio.setTag(pin);
    radio.setEnabled(!usedPin(pin.getPinNumber()));
    radio.setOnCheckedChangeListener((compoundButton, b) -> {
        if (b) {
            mSelectedPin = pin;
        }
    });
    return radio;
}
 
Example 12
Source File: RadioButtonRowWithSubheading.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
  super.onFinishInflate();

  // Wait until this view is fully constructed before passing it into the
  // RadioButtonRowOnClickListener constructor because it expects a fully constructed
  // RadioButtonRowWithSubheading.
  this.setOnClickListener(new RadioButtonRowOnClickListener(this));

  // We need to wait until the view has finished inflating to initialize to ensure all the child
  // views are non-null.
  for (int i = 0; i < getChildCount(); i++) {
    View childView = getChildAt(i);
    if (childView instanceof RadioButton) {
      // The first radio button in the hierarchy will be used as the radio button for this row.
      // Additional radio buttons in the hierarchy will be ignored.
      radioButton = (RadioButton) childView;
      radioButton.setOnCheckedChangeListener(
          (buttonView, isChecked) -> {
            ViewParent parent = getParent();
            if (isChecked && parent instanceof RadioGroupWithSubheadings) {
              ((RadioGroupWithSubheadings) parent).check(radioButton.getId());
            }
          });
      break;
    }
  }
}
 
Example 13
Source File: LanguageFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.intro_language, container, false);
    RadioGroup radioGroup = v.findViewById(R.id.radioGroup);
    
    List<LocaleUtils.Translation> langs = LocaleUtils.getSupportedLanguages(getActivity());
    String currentLang = Preferences.LANGUAGE.get();
    int pos = 0;
    for (int i = 0; i < langs.size(); i++) {
        LocaleUtils.Translation lang = langs.get(i);
        if (lang.getLanguage().equals(currentLang))
            pos = i + 1;
        RadioButton button = new RadioButton(getContext());
        button.setTag(lang.getLanguage());
        button.setText(lang.getDisplayText());
        button.setTextColor(getResources().getColor(R.color.white));
        button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        int padding = (int) (button.getTextSize() / 2);
        button.setPadding(padding, padding, padding, padding);
        button.setOnCheckedChangeListener(this);
        radioGroup.addView(button);
    }
    if (pos != 0)
        ((RadioButton) radioGroup.getChildAt(pos)).setChecked(true);
    return v;
}
 
Example 14
Source File: SelectOneWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
public void unsetListeners() {
    super.unsetListeners();

    for (RadioButton button : this.buttons) {
        button.setOnCheckedChangeListener(null);
        button.setOnLongClickListener(null);
    }
}
 
Example 15
Source File: MainTabActivity.java    From coolreader with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.tab_main);
	LocalActivityManager lam = new LocalActivityManager(this, true);  
       lam.dispatchCreate(savedInstanceState);  
       
	thMain = (TabHost)findViewById(android.R.id.tabhost);
	thMain.setup(lam);
	thMain.addTab(newTabSpec(TAB_BOOKSHELF, R.string.tab_bookshelf, R.drawable.tab_bookshelf, new Intent(this,BookshelfActivity.class)));
	thMain.addTab(newTabSpec(TAB_BOOKMARK, R.string.tab_bookmark, R.drawable.tab_bookmark, new Intent(this,BookmarkActivity.class)));
	thMain.addTab(newTabSpec(TAB_BOOK_ONLINE, R.string.tab_book_online, R.drawable.tab_book_online, new Intent(this,MainActivity.class)));
	
	rbtnBookshelf = (RadioButton)findViewById(R.id.radio_button0);
	rbtnbookmark = (RadioButton)findViewById(R.id.radio_button1);
	rbtnBookOnline = (RadioButton)findViewById(R.id.radio_button2);
	
	rbtnBookshelf.setOnCheckedChangeListener(this);
	rbtnbookmark.setOnCheckedChangeListener(this);
	rbtnBookOnline.setOnCheckedChangeListener(this);
	
	File file = new File("/mnt/sdcard/DotcoolReader");
	if(!file.exists()){
		file.mkdir();
	}
	
}
 
Example 16
Source File: RadioButtonGroupHelper.java    From AndroidProject with Apache License 2.0 5 votes vote down vote up
public RadioButtonGroupHelper(View rootView, @IdRes int... ids) {
    mViewSet = new ArrayList<>(ids.length - 1);
    for (@IdRes int id : ids) {
        RadioButton view = rootView.findViewById(id);
        view.setOnCheckedChangeListener(this);
        mViewSet.add(view);
    }
}
 
Example 17
Source File: FsBrowserRecord.java    From edslite with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void updateView(View view, final int position)
{
    final FileListViewFragment hf = getHostFragment();
    //if(isSelected())
    //    //noinspection deprecation
    //    view.setBackgroundDrawable(getSelectedBackgroundDrawable(_context));
    CheckBox cb = view.findViewById(android.R.id.checkbox);
    if(cb!=null)
    {
        if(allowSelect() && (_host.isSelectAction() || hf.isInSelectionMode()) && (!_host.isSelectAction() || !_host.isSingleSelectionMode()))
        {
            cb.setOnCheckedChangeListener(null);
            cb.setChecked(isSelected());
            cb.setOnCheckedChangeListener((compoundButton, isChecked) ->
            {
                if(isChecked)
                    hf.selectFile(FsBrowserRecord.this);
                else
                    hf.unselectFile(FsBrowserRecord.this);
            });
            cb.setVisibility(View.VISIBLE);
        }
        else
            cb.setVisibility(View.INVISIBLE);
    }
    RadioButton rb = view.findViewById(R.id.radio);
    if(rb!=null)
    {
        if(allowSelect() && _host.isSelectAction() && _host.isSingleSelectionMode())
        {
            rb.setOnCheckedChangeListener(null);
            rb.setChecked(isSelected());
            rb.setOnCheckedChangeListener((compoundButton, isChecked) ->
            {
                if(isChecked)
                    hf.selectFile(FsBrowserRecord.this);
                else
                   hf.unselectFile(FsBrowserRecord.this);
            });
            rb.setVisibility(View.VISIBLE);
        }
        else
            rb.setVisibility(View.INVISIBLE);
    }

    TextView tv = view.findViewById(android.R.id.text1);
 	tv.setText(getName());

    ImageView iv = view.findViewById(android.R.id.icon);
    iv.setImageDrawable(getDefaultIcon());
    iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    iv.setOnClickListener(view1 ->
    {
        if (allowSelect())
        {
            if(isSelected())
            {
                if(!_host.isSelectAction() || !_host.isSingleSelectionMode())
                    hf.unselectFile(FsBrowserRecord.this);
            }
            else
                hf.selectFile(FsBrowserRecord.this);
        }
    });

    iv = view.findViewById(android.R.id.icon1);
    if(_miniIcon == null)
        iv.setVisibility(View.INVISIBLE);
    else
    {
        iv.setImageDrawable(_miniIcon);
        iv.setVisibility(View.VISIBLE);
    }
}
 
Example 18
Source File: MainActivity.java    From TextCounter with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    builder = TextCounter.newBuilder();

    textView = (TextView) findViewById(R.id.textView);
    round = (TextView) findViewById(R.id.round);
    fps = (TextView) findViewById(R.id.fps);
    duration = (TextView) findViewById(R.id.duration);

    swipe = (ImageView) findViewById(R.id.swipe);
    swipe.setOnClickListener(this);

    spinner = (Spinner) findViewById(R.id.spinner);

    from = (EditText) findViewById(R.id.from);
    to = (EditText) findViewById(R.id.to);
    from.addTextChangedListener(this);

    builder.setTextView(textView);

    seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
    seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
    seekBar3 = (SeekBar) findViewById(R.id.seekBar3);
    seekBar1.setOnSeekBarChangeListener(this);
    seekBar2.setOnSeekBarChangeListener(this);
    seekBar3.setOnSeekBarChangeListener(this);

    start = (Button) findViewById(R.id.start);
    start.setOnClickListener(this);

    button1 = (RadioButton) findViewById(R.id.radioButton1);
    button2 = (RadioButton) findViewById(R.id.radioButton2);
    button3 = (RadioButton) findViewById(R.id.radioButton3);
    button4 = (RadioButton) findViewById(R.id.radioButton4);
    button5 = (RadioButton) findViewById(R.id.radioButton5);
    button6 = (RadioButton) findViewById(R.id.radioButton6);

    button1.setOnCheckedChangeListener(this);
    button2.setOnCheckedChangeListener(this);
    button3.setOnCheckedChangeListener(this);
    button4.setOnCheckedChangeListener(this);
    button5.setOnCheckedChangeListener(this);
    button6.setOnCheckedChangeListener(this);

    button1.setChecked(true);

    seekBar1.setProgress(0);
    seekBar2.setProgress(24);
    seekBar3.setProgress(1);

    builder.setTextView(textView);

    textView.setVisibility(View.VISIBLE);
}
 
Example 19
Source File: SelectOneWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    int padding = (int)Math.floor(context.getResources().getDimension(R.dimen.select_padding));

    mItems = getSelectChoices();
    buttons = new Vector<>();

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = prompt.getAnswerValue().uncast().getString();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {
            final RadioButton rb = new RadioButton(getContext());
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                rb.setText(forceMarkdown(markdownText));
            } else {
                rb.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
            rb.setId(i + buttonIdBase);
            rb.setEnabled(!prompt.isReadOnly());
            rb.setFocusable(!prompt.isReadOnly());

            rb.setBackgroundResource(R.drawable.selector_button_press);

            buttons.add(rb);

            if (mItems.get(i).getValue().equals(s)) {
                rb.setChecked(true);
            }

            //Move to be below the above setters. Not sure if that will cause
            //problems, but I don't think it should.
            rb.setOnCheckedChangeListener(this);

            String audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), rb, audioURI, imageURI, videoURI, bigImageURI);
            mediaLayout.setPadding(0, padding, 0, padding);
            mediaLayout.setEnabled(!mPrompt.isReadOnly());
            mediaLayout.setOnClickListener(v -> rb.performClick());
            addView(mediaLayout);


            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                addView(divider);
            }
        }
        addClearButton(context, s != null && !prompt.isReadOnly());
    }
}
 
Example 20
Source File: SelectOneAutoAdvanceWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    LayoutInflater inflater = LayoutInflater.from(getContext());

    mItems = getSelectChoices();
    buttons = new Vector<>();
    listener = (AdvanceToNextListener)context;

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {

            RelativeLayout thisParentLayout =
                    (RelativeLayout)inflater.inflate(R.layout.quick_select_layout, null);

            final LinearLayout questionLayout = (LinearLayout)thisParentLayout.getChildAt(0);
            ImageView rightArrow = (ImageView)thisParentLayout.getChildAt(1);

            final RadioButton r = new RadioButton(getContext());
            r.setOnCheckedChangeListener(this);
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                r.setText(forceMarkdown(markdownText));
            } else {
                r.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);
            r.setId(i + buttonIdBase);
            r.setEnabled(!prompt.isReadOnly());
            r.setFocusable(!prompt.isReadOnly());

            Drawable image = getResources().getDrawable(R.drawable.icon_auto_advance_arrow);
            rightArrow.setImageDrawable(image);
            rightArrow.setOnTouchListener((v, event) -> {
                r.onTouchEvent(event);
                return false;
            });

            buttons.add(r);

            if (mItems.get(i).getValue().equals(s)) {
                r.setChecked(true);
            }

            String audioURI = null;
            audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI = null;
            imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), r, audioURI, imageURI, videoURI, bigImageURI);

            questionLayout.addView(mediaLayout);

            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                mediaLayout.addDivider(divider);
            }

            addView(thisParentLayout);
        }
    }
}