Java Code Examples for android.support.v7.widget.AppCompatRadioButton#setText()
The following examples show how to use
android.support.v7.widget.AppCompatRadioButton#setText() .
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: SingleChooseDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: DialogLPV.java From LockPattern with MIT License | 5 votes |
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); }
Example 3
Source File: SettingFragment.java From ClassSchedule with Apache License 2.0 | 4 votes |
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)); } } }); }
Example 4
Source File: ConsentQuizQuestionStepLayout.java From ResearchStack with Apache License 2.0 | 4 votes |
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; } } } }
Example 5
Source File: RadioGroup.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
@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); }