當前位置: 首頁>>代碼示例>>Java>>正文


Java RadioButton.setButtonDrawable方法代碼示例

本文整理匯總了Java中android.widget.RadioButton.setButtonDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java RadioButton.setButtonDrawable方法的具體用法?Java RadioButton.setButtonDrawable怎麽用?Java RadioButton.setButtonDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.RadioButton的用法示例。


在下文中一共展示了RadioButton.setButtonDrawable方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setTint

import android.widget.RadioButton; //導入方法依賴的package包/類
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            // Rdio button includes own alpha for disabled state
            ColorUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)),
            ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
        radioButton.setButtonDrawable(d);
    }
}
 
開發者ID:GlennioTech,項目名稱:MetadataEditor,代碼行數:19,代碼來源:TintHelper.java

示例2: tint

import android.widget.RadioButton; //導入方法依賴的package包/類
/**
 * Tint the radio button
 *
 * @param radioButton the radio button
 * @param color       the color
 */
public static void tint(@NonNull RadioButton radioButton, @ColorInt int color) {
    final int disabledColor = getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            getThemeAttrColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
 
開發者ID:jumaallan,項目名稱:AndelaTrackChallenge,代碼行數:29,代碼來源:Easel.java

示例3: setTint

import android.widget.RadioButton; //導入方法依賴的package包/類
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            // Rdio button includes own alpha for disabled state
            ATEUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)),
            ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
        radioButton.setButtonDrawable(d);
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:19,代碼來源:TintHelper.java

示例4: setRadioButtonDrawable

import android.widget.RadioButton; //導入方法依賴的package包/類
private static void setRadioButtonDrawable(Context context, RadioButton button,
                                           @DrawableRes int id) {
    ColorStateList list = new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_checked },
            new int[] { android.R.attr.state_checked }
    }, new int[] {
            ThemeUtils.getColor(context, R.attr.compose_image_button_tint),
            ThemeUtils.getColor(context, R.attr.colorAccent)
    });
    Drawable drawable = VectorDrawableCompat.create(context.getResources(), id,
            context.getTheme());
    if (drawable == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        button.setButtonTintList(list);
    } else {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable, list);
    }
    button.setButtonDrawable(drawable);
}
 
開發者ID:Vavassor,項目名稱:Tusky,代碼行數:23,代碼來源:ComposeOptionsFragment.java

示例5: setTint

import android.widget.RadioButton; //導入方法依賴的package包/類
public static void setTint(@NonNull RadioButton radioButton,
                           @NonNull ColorStateList colors) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(colors);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(),
                R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, colors);
        radioButton.setButtonDrawable(d);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:MDTintHelper.java

示例6: initCheckGroup

import android.widget.RadioButton; //導入方法依賴的package包/類
private void initCheckGroup(final OrderTestModel.OrderItemCheckListBean model, LayoutInflater inflater) {
        for (int z = 0; z < model.checkItemSuggestions.size(); z++) {
            final OrderTestModel.OrderItemCheckListBean.CheckItemSuggestionsBean item = model.checkItemSuggestions.get(z);
//            final RadioButton ckview = (RadioButton)inflater.inflate(R.layout.fragment_test_item_ck, null);
            final RadioButton ckview = new RadioButton(activity);
            ckview.setText(item.suggestionOption);
            if (item.isChecked.equals("1")) {
                checkId = item.checkItemSuggestionsId;
                ckview.setChecked(true);
            } else {
                ckview.setChecked(false);
            }
            ckview.setTag(item.checkItemSuggestionsId);
            ckview.setTextColor(this.getResources().getColor(R.color.gray_text));
            ckview.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT));
            ckview.setTextSize(18);
            ckview.setId(z);
            ckview.setPadding(2, 0, 12, 0);
            ckview.setGravity(Gravity.CENTER | left);
            Drawable drawable = getResources().getDrawable(
                    R.drawable.checkbox_selector_circle_bac);
            // 這一步必須要做,否則不會顯示.
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                    drawable.getMinimumHeight());
            ckview.setCompoundDrawables(drawable, null, null, null);
            ckview.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkId = (String) ckview.getTag();
                }
            });
            llsugestcontain.addView(ckview);
        }
    }
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:35,代碼來源:TestItemView.java

示例7: setImage

import android.widget.RadioButton; //導入方法依賴的package包/類
public void setImage(ArrayList<Integer> imageList) {
	for (int i = 0; i < imageList.size(); i++) {
		Integer imageID = ((Integer) imageList.get(i)).intValue();
		ImageView iv = new ImageView(mContext);
		iv.setLayoutParams(new LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		iv.setScaleType(ImageView.ScaleType.FIT_XY);
		iv.setImageResource(imageID);
		iv.setOnClickListener(this);
		mViewList.add(iv);
	}
	mPager.setAdapter(new ImageAdapater());
	mPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
		@Override
		public void onPageSelected(int position) {
			setButton(position);
		}
	});

	mCount = imageList.size();
	for (int i = 0; i < mCount; i++) {
		RadioButton radio = new RadioButton(mContext);
		radio.setLayoutParams(new RadioGroup.LayoutParams(dip_15, dip_15));
		radio.setGravity(Gravity.CENTER);
		radio.setButtonDrawable(R.drawable.indicator_selector);
		mGroup.addView(radio);
	}
	mPager.setCurrentItem(0);
	setButton(0);
}
 
開發者ID:Luodian,項目名稱:Shared-Route,代碼行數:31,代碼來源:BannerPager.java

示例8: addIndex

import android.widget.RadioButton; //導入方法依賴的package包/類
/**
 * 添加指示器
 */
private void addIndex(){
    RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10,0,10,0);
    RadioButton radioButton = new RadioButton(getContext());
    radioButton.setLayoutParams(layoutParams);
    radioButton.setButtonDrawable(indicatorResId);
    radioButton.setEnabled(false);
    buttons.add(radioButton);
}
 
開發者ID:Militch,項目名稱:banner-holder,代碼行數:13,代碼來源:BannerHolderView.java


注:本文中的android.widget.RadioButton.setButtonDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。