Java Code Examples for android.widget.RadioButton#setTextColor()
The following examples show how to use
android.widget.RadioButton#setTextColor() .
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: FlatTabGroup.java From support with Apache License 2.0 | 7 votes |
private void generateTabView(Context context, AttributeSet attrs) { if (mItemString == null) { return; } mTabViewIds = new int[mItemString.length]; int i = 0; for (String text : mItemString) { RadioButton button = new RadioButton(context, attrs); button.setGravity(Gravity.CENTER); button.setButtonDrawable(android.R.color.transparent); button.setText(text); button.setTextColor(mTextColor); button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); int id = generateViewId(); button.setId(mTabViewIds[i++] = id); addView(button, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); } }
Example 2
Source File: RecyclerViewScrollActivity.java From AndroidDemo with MIT License | 6 votes |
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 3
Source File: HorizontalScrollMenu.java From HorizontalScrollMenu with Apache License 2.0 | 6 votes |
/** * 初始化菜单项 * * @param items */ private void initMenuItems(List<String> items) { if (null != items && 0 != items.size()) { rg_items.setOnCheckedChangeListener(mItemListener); for (String str : items) { RadioButton rb_item = (RadioButton) LayoutInflater.from( mContext).inflate(R.layout.menu_item, null); rb_item.setTextColor(mColors); rb_item.setText(str); rb_item.setGravity(Gravity.CENTER); rb_item.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); rg_items.addView(rb_item); rb_items.add(rb_item); } rb_items.get(0).setChecked(true); } }
Example 4
Source File: MenuDialogAdapter.java From MarketAndroidApp with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_item, null); } //绑定item内的TextView和RadioButton TextView nameText = MenuDialogAdapterViewHolder.get(convertView, R.id.menu_item_textview); RadioButton clickButton = MenuDialogAdapterViewHolder.get(convertView, R.id.radioButton); clickButton.setChecked(selectedPos == position);//改变点击选中状态 //修改item高度,使其达到甲方要求的每页10个item显示要求 ViewGroup.LayoutParams lp = nameText.getLayoutParams(); lp.height = parent.getHeight() / 10; //获取选中的item的标题 CommodityTypeModel menuData = menuDatas.get(position); String str = menuData.getName(); nameText.setText(str);//设置标题 convertView.setSelected(selectedPos == position);//设置选中时的view nameText.setSelected(selectedPos == position);//判断菜单的点击状态 //选中后的标题字体及RadioButton颜色 nameText.setTextColor(selectedPos == position ? 0xFF387ef5 : 0xFF222222); clickButton.setTextColor(selectedPos == position ? 0xFF787878 : 0xFF387ef5); return convertView; }
Example 5
Source File: DeviceFragment.java From android-showcase-template with Apache License 2.0 | 5 votes |
/** * Function to allow updates to the radio buttons UI when a security check has failed Passed * tests do not need updating due to being the default UI state * * @param uiElement - the UI element to update * @param textResource - the text resource to set the updates text for */ public void setCheckFailed(RadioButton uiElement, int textResource) { totalTestFailures++; uiElement.setText(textResource); uiElement.setTextColor(getResources().getColor(R.color.red)); uiElement.setButtonDrawable(R.drawable.baseline_warning); uiElement.setButtonTintList(ColorStateList.valueOf(getResources().getColor(R.color.red))); }
Example 6
Source File: NavView.java From TabPager with Apache License 2.0 | 5 votes |
/** * 设置Tab样式 * * @param rb Tab项 * @param checked 是否选中 */ private void setTabStyle(RadioButton rb, boolean checked) { if (checked) { rb.setTextColor(mNavTextCheckedColor); if (null == mNavBgCheckedImg) { rb.setBackgroundColor(mNavBgCheckedColor); } else { rb.setBackgroundDrawable(mNavBgCheckedImg); } } else { rb.setTextColor(mNavTextDefaultColor); rb.setBackgroundColor(Color.TRANSPARENT); rb.setBackgroundDrawable(null); } }
Example 7
Source File: LanguageFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@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 8
Source File: NavView.java From TabPager with Apache License 2.0 | 5 votes |
/** * 设置Tab样式 * * @param rb Tab项 * @param checked 是否选中 */ private void setTabStyle(RadioButton rb, boolean checked) { if (checked) { rb.setTextColor(mNavTextCheckedColor); if (null == mNavBgCheckedImg) { rb.setBackgroundColor(mNavBgCheckedColor); } else { rb.setBackgroundDrawable(mNavBgCheckedImg); } } else { rb.setTextColor(mNavTextDefaultColor); rb.setBackgroundColor(Color.TRANSPARENT); rb.setBackgroundDrawable(null); } }
Example 9
Source File: LanguageFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@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 10
Source File: FABActivity.java From fab with Apache License 2.0 | 5 votes |
private void populateColorsRadioGroup(RadioGroup group, Set<RadioButtons.ColorsInfo> colorsInfos) { for (RadioButtons.ColorsInfo colorsInfo : colorsInfos) { final RadioButton button = new RadioButton(this); final String text = getResources().getString(colorsInfo.colorTextResId); final int color = getResources().getColor(colorsInfo.primaryColorResId); final int textColor = color == getResources().getColor(R.color.fab_material_white) ? getResources().getColor(R.color.fab_material_black) : color; button.setId(IdGenerator.next()); button.setText(text); button.setTextColor(textColor); button.setTag(colorsInfo); group.addView(button); } }
Example 11
Source File: SwitchButton.java From SwitchButton with Apache License 2.0 | 5 votes |
private RadioButton createRadioView() { RadioButton mRadioButton = new RadioButton(getContext(), null, mRadioStyle > 0 ? mRadioStyle : android.R.attr.radioButtonStyle); if (mRadioStyle == 0) { mRadioButton.setGravity(Gravity.CENTER); mRadioButton.setEllipsize(TruncateAt.END); } if (mTextColor != null) mRadioButton.setTextColor(mTextColor); if (textSize > 0) mRadioButton.setTextSize(textSize); return mRadioButton; }
Example 12
Source File: AbstractWeeklySchedulerFragment.java From arcusandroid with Apache License 2.0 | 4 votes |
@Override public void onResume() { super.onResume(); getActivity().setTitle(getTitle()); // Initialize color scheme per edit mode noSchedulesCopyTitle.setTextColor(isEditMode() ? Color.WHITE : Color.BLACK); noSchedulesCopyDesc.setTextColor(isEditMode() ? getResources().getColor(R.color.white_with_35) : getResources().getColor(R.color.black_with_60)); addEventButton.setColorScheme(isEditMode() ? Version1ButtonColor.WHITE : Version1ButtonColor.BLACK); for (int buttonIndex = 0; buttonIndex < dayOfWeekGroup.getChildCount(); buttonIndex++) { RadioButton thisButton = (RadioButton) dayOfWeekGroup.getChildAt(buttonIndex); thisButton.setTextColor(isEditMode() ? getResources().getColorStateList(R.color.radio_text_white) : getResources().getColorStateList(R.color.radio_text_black)); thisButton.setBackgroundResource(isEditMode() ? R.drawable.day_of_week_radio_drawable_white : R.drawable.day_of_week_radio_drawable_black); } if (isEditMode()) { ImageManager.with(getActivity()).setWallpaper(Wallpaper.ofCurrentPlace().darkened()); } else { ImageManager.with(getActivity()).setWallpaper(Wallpaper.ofCurrentPlace().lightend()); } addEventButton.setColorScheme(Version1ButtonColor.WHITE); dayOfWeekGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { onDayOfWeekChanged(getSelectedDayOfWeek()); } }); addEventButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onAddCommand(); } }); schedulesList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { onEditCommand(parent.getAdapter().getItem(position)); } }); }
Example 13
Source File: ThemeHelper.java From Liz with GNU General Public License v3.0 | 4 votes |
public void themeRadioButton(RadioButton radioButton) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(getTintList()); radioButton.setTextColor(getTextColor()); } }
Example 14
Source File: ThemeHelper.java From Android-AudioRecorder-App with Apache License 2.0 | 4 votes |
public void themeRadioButton(RadioButton radioButton) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(getTintList()); radioButton.setTextColor(getTextColor()); } }