public @IdRes
    int[] addButtons(@StringRes final int... textIds) {
        final LayoutInflater inflater = LayoutInflater.from(getContext());
        final int[] result = new int[textIds.length];

        for (int idx = 0; idx < textIds.length; idx++) {
            final Button b = (Button) inflater.inflate(R.layout.button_view, this, false);
            final int id = View.generateViewId();
            b.setId(id);
            b.setText(textIds[idx]);
            result[idx] = id;
            addToView(b, 0, 0);
        }

        if (this.isSelectionRequired() && this.getCheckedButtonIds().isEmpty()) {
            //if nothing is selected but selection is required, then select the first item which was just added
            ((MaterialButton) this.getChildAt(this.getChildCount() - textIds.length)).setChecked(true);
        }

        return result;
    }
adds text buttons to this buttontogglegroup
main/src/main/java/cgeo/geocaching/ui/ButtonToggleGroup.java