android.widget.RadioButton#setTextColor ( )源码实例Demo

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

源代码1 项目: support   文件: FlatTabGroup.java
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));
    }
}
 
源代码2 项目: AndroidDemo   文件: RecyclerViewScrollActivity.java
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);
}
 
/**
 * 初始化菜单项
 * 
 * @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);
	}

}
 
源代码4 项目: MarketAndroidApp   文件: MenuDialogAdapter.java
@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;
}
 
/**
 * 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)));

}
 
源代码6 项目: TabPager   文件: NavView.java
/**
 * 设置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);
    }
}
 
源代码7 项目: prayer-times-android   文件: LanguageFragment.java
@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;
}
 
源代码8 项目: TabPager   文件: NavView.java
/**
 * 设置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);
    }
}
 
源代码9 项目: prayer-times-android   文件: LanguageFragment.java
@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;
}
 
源代码10 项目: fab   文件: FABActivity.java
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);
	}
}
 
源代码11 项目: SwitchButton   文件: SwitchButton.java
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;
}
 
@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));
        }
    });
}
 
源代码13 项目: Liz   文件: ThemeHelper.java
public void themeRadioButton(RadioButton radioButton) {
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		radioButton.setButtonTintList(getTintList());
		radioButton.setTextColor(getTextColor());
	}
}
 
源代码14 项目: Android-AudioRecorder-App   文件: ThemeHelper.java
public void themeRadioButton(RadioButton radioButton) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    radioButton.setButtonTintList(getTintList());
    radioButton.setTextColor(getTextColor());
  }
}