Java Code Examples for android.widget.RadioButton#setBackgroundResource()
The following examples show how to use
android.widget.RadioButton#setBackgroundResource() .
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: BannerView.java From MvpRoute with Apache License 2.0 | 6 votes |
@NonNull private RadioButton initData(int length, int i, Object imagepath) { initImageView(i, imagepath); RadioButton radioButton = new RadioButton(context); if (selectTab != 0) { radioButton.setBackgroundResource(selectTab); radioButton.setButtonDrawable(context.getResources().getDrawable(android.R.color.transparent)); } RadioGroup.LayoutParams buttonParams = new RadioGroup.LayoutParams(tabWidth, tabHeight); if (i != length - 1) { buttonParams.setMargins(0, 0, tabMargin, 0); } radioButton.setLayoutParams(buttonParams); radioButton.setId(i); if (i == 0) radioButton.setChecked(true); return radioButton; }
Example 2
Source File: WizardFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
private void createRadioButtons() { // set button dimension int buttonSize = AptoideUtils.ScreenU.getPixelsForDip(10, getResources()); ViewGroup.LayoutParams buttonLayoutParams = new RadioGroup.LayoutParams(buttonSize, buttonSize); // set button margin int buttonMargin = AptoideUtils.ScreenU.getPixelsForDip(2, getResources()); ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) buttonLayoutParams; marginLayoutParams.setMargins(buttonMargin, buttonMargin, buttonMargin, buttonMargin); final int pages = viewPagerAdapter.getCount(); wizardButtons = new ArrayList<>(pages); Context context = getContext(); for (int i = 0; i < pages; i++) { RadioButton radioButton = new RadioButton(context); radioButton.setLayoutParams(buttonLayoutParams); radioButton.setButtonDrawable(android.R.color.transparent); radioButton.setBackgroundResource(R.drawable.wizard_custom_indicator); radioButton.setClickable(false); radioGroup.addView(radioButton); wizardButtons.add(radioButton); } }
Example 3
Source File: HorizontalScrollMenu.java From HorizontalScrollMenu with Apache License 2.0 | 6 votes |
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub RadioButton btn = (RadioButton) group.findViewById(checkedId); setMenuItemsNullBackground(); btn.setBackgroundResource(mBackgroundResId); btn.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); int position = 0; for (int i = 0; i < rb_items.size(); i++) { if (rb_items.get(i) == btn) { position = i; } } vp_content.setCurrentItem(position, mSwiped); moveItemToCenter(btn); mAdapter.onPageChanged(position, mVisitStatus[position]); mVisitStatus[position] = true; }
Example 4
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 5
Source File: SelectOneWidget.java From commcare-android with Apache License 2.0 | 4 votes |
public SelectOneWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); int padding = (int)Math.floor(context.getResources().getDimension(R.dimen.select_padding)); mItems = getSelectChoices(); buttons = new Vector<>(); String s = null; if (prompt.getAnswerValue() != null) { s = prompt.getAnswerValue().uncast().getString(); } //Is this safe enough from collisions? buttonIdBase = Math.abs(prompt.getIndex().hashCode()); if (mItems != null) { for (int i = 0; i < mItems.size(); i++) { final RadioButton rb = new RadioButton(getContext()); String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i)); if (markdownText != null) { rb.setText(forceMarkdown(markdownText)); } else { rb.setText(prompt.getSelectChoiceText(mItems.get(i))); } rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize); rb.setId(i + buttonIdBase); rb.setEnabled(!prompt.isReadOnly()); rb.setFocusable(!prompt.isReadOnly()); rb.setBackgroundResource(R.drawable.selector_button_press); buttons.add(rb); if (mItems.get(i).getValue().equals(s)) { rb.setChecked(true); } //Move to be below the above setters. Not sure if that will cause //problems, but I don't think it should. rb.setOnCheckedChangeListener(this); String audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO); String imageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE); String videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video"); String bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image"); MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), rb, audioURI, imageURI, videoURI, bigImageURI); mediaLayout.setPadding(0, padding, 0, padding); mediaLayout.setEnabled(!mPrompt.isReadOnly()); mediaLayout.setOnClickListener(v -> rb.performClick()); addView(mediaLayout); // Last, add the dividing line (except for the last element) ImageView divider = new ImageView(getContext()); divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright); if (i != mItems.size() - 1) { addView(divider); } } addClearButton(context, s != null && !prompt.isReadOnly()); } }