android.support.v7.widget.AppCompatRadioButton#setText ( )源码实例Demo

下面列出了android.support.v7.widget.AppCompatRadioButton#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AssistantBySDK   文件: SingleChooseDialog.java
private void init() {
    mRgChoice.setVisibility(View.VISIBLE);
    mChoiceBox.setVisibility(View.GONE);
    mScdTitle.setText(title);
    for (int i = 0; i < datas.length; i++) {
        AppCompatRadioButton arb = new AppCompatRadioButton(mContext);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, ScreenUtil.getInstance().dip2px(48));
        arb.setLayoutParams(layoutParams);
        arb.setGravity(Gravity.CENTER_VERTICAL);
        arb.setId(i);
        arb.setText(datas[i]);
        arb.setTextSize(15);
        arb.setTextColor(mContext.getResources().getColor(R.color.new_text_color_first));
        arb.setPadding(ScreenUtil.getInstance().dip2px(16), 0, 0, 0);
        if (i == 0)
            arb.setChecked(true);
        mRgChoice.addView(arb);
    }
}
 
源代码2 项目: LockPattern   文件: DialogLPV.java
private void setQuestionItem(int pos, AppCompatRadioButton rb, ViewGroup.LayoutParams lp,
                             ColorStateList csl){
    rb.setLayoutParams(lp);
    rb.setTag(pos);
    rb.setTextColor(mTextColor);
    rb.setTextSize(mTextSize);
    rb.setText(mQuestionsArray[pos]);
    rb.setOnClickListener(onQuestionItemListener);
    rb.setSupportButtonTintList(csl);

    mQuestionRBtnsList.add(rb);
}
 
源代码3 项目: ClassSchedule   文件: SettingFragment.java
private void showThemeDialog() {
    ScrollView scrollView = new ScrollView(getActivity());
    RadioGroup radioGroup = new RadioGroup(getActivity());
    scrollView.addView(radioGroup);
    int margin = ScreenUtils.dp2px(16);
    radioGroup.setPadding(margin / 2, margin, margin, margin);

    for (int i = 0; i < themeColorArray.length; i++) {
        AppCompatRadioButton arb = new AppCompatRadioButton(getActivity());

        RadioGroup.LayoutParams params =
                new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT);

        arb.setLayoutParams(params);
        arb.setId(i);
        arb.setTextColor(getResources().getColor(themeColorArray[i]));
        arb.setText(themeNameArray[i]);
        arb.setTextSize(16);
        arb.setPadding(0, margin / 2, 0, margin / 2);
        radioGroup.addView(arb);
    }

    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            theme = checkedId;
        }
    });

    DialogHelper dialogHelper = new DialogHelper();
    dialogHelper.showCustomDialog(getActivity(), scrollView,
            getString(R.string.theme_preference), new DialogListener() {
                @Override
                public void onPositive(DialogInterface dialog, int which) {
                    super.onPositive(dialog, which);
                    dialog.dismiss();
                    String key = getString(R.string.app_preference_theme);
                    int oldTheme = Preferences.getInt(key, 0);

                    if (theme != oldTheme) {
                        Preferences.putInt(key, theme);
                        ActivityUtil.finishAll();
                        startActivity(new Intent(app.mContext, CourseActivity.class));
                    }
                }
            });
}
 
public void initializeStep() {
    setOrientation(VERTICAL);

    ConsentQuizModel.QuizQuestion question = step.getQuestion();
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.rss_layout_quiz_question, this, true);

    ((TextView) findViewById(R.id.title)).setText(step.getTitle());

    radioGroup = (RadioGroup) findViewById(R.id.radio_group);

    submitBar = (SubmitBar) findViewById(R.id.submit_bar);
    submitBar.getNegativeActionView().setVisibility(GONE);

    resultTitle = (TextView) findViewById(R.id.quiz_result_title);
    resultSummary = (TextView) findViewById(R.id.quiz_result_summary);

    radioItemBackground = findViewById(R.id.quiz_result_item_background);

    if (question.getType().equals("instruction")) {
        TextView instructionText = (TextView) findViewById(R.id.instruction_text);
        instructionText.setText(question.getText());
        instructionText.setVisibility(VISIBLE);

        // instruction steps don't need submit, also always count as correct answer
        submitBar.setPositiveTitle(R.string.rsb_next);
        submitBar.setPositiveAction(v -> onNext(true));
    } else {
        submitBar.setPositiveTitle(R.string.rsb_submit);
        submitBar.setPositiveAction(v -> onSubmit());

        for (Choice<String> choice : getChoices(question)) {
            AppCompatRadioButton button = (AppCompatRadioButton) inflater.inflate(R.layout.rss_item_radio_quiz,
                    radioGroup,
                    false);
            button.setText(choice.getText());
            button.setTag(choice);
            radioGroup.addView(button);

            if (question.getExpectedAnswer().equals(choice.getValue())) {
                expectedChoice = choice;
            }
        }
    }
}
 
源代码5 项目: android_maplibui   文件: RadioGroup.java
@Override
public void init(JSONObject element,
                 List<Field> fields,
                 Bundle savedState,
                 Cursor featureCursor,
                 SharedPreferences preferences,
                 Map<String, Map<String, String>> translations) throws JSONException{

    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_NAME_KEY);
    mIsShowLast = ControlHelper.isSaveLastValue(attributes);
    boolean isEnabled = ControlHelper.isEnabled(fields, mFieldName);
    setEnabled(isEnabled);

    String lastValue = null;
    if (ControlHelper.hasKey(savedState, mFieldName))
        lastValue = savedState.getString(ControlHelper.getSavedStateKey(mFieldName));
    else if (null != featureCursor) { // feature exists
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0)
            lastValue = featureCursor.getString(column);
    } else if (mIsShowLast)
        lastValue = preferences.getString(mFieldName, null);

    JSONArray values = attributes.getJSONArray(JSON_VALUES_KEY);
    int position = Constants.NOT_FOUND;
    mAliasValueMap = new HashMap<>();

    for (int j = 0; j < values.length(); j++) {
        JSONObject keyValue = values.getJSONObject(j);
        String value = keyValue.getString(JSON_VALUE_NAME_KEY);
        String value_alias = keyValue.getString(JSON_VALUE_ALIAS_KEY);

        if (lastValue == null && keyValue.has(JSON_DEFAULT_KEY) && keyValue.getBoolean(JSON_DEFAULT_KEY)) {
            position = j;
        }

        if (lastValue != null && lastValue.equals(value)) { // if modify data
            position = j;
        }

        mAliasValueMap.put(value_alias, value);
        AppCompatRadioButton radioButton = new AppCompatRadioButton(getContext());
        radioButton.setText(value_alias);
        radioButton.setEnabled(isEnabled);
        addView(radioButton);
    }

    if (getChildAt(position) != null)
        check(getChildAt(position).getId());
    setOrientation(RadioGroup.VERTICAL);
}