use of android.widget.RadioButton in project RxBinding by JakeWharton.
the class RxRadioGroupTest method setUp.
@Before
public void setUp() {
RadioButton button1 = new RadioButton(context);
button1.setId(1);
view.addView(button1);
RadioButton button2 = new RadioButton(context);
button2.setId(2);
view.addView(button2);
}
use of android.widget.RadioButton in project SeeWeather by xcc3641.
the class SettingFragment method showIconDialog.
private void showIconDialog() {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogLayout = inflater.inflate(R.layout.dialog_icon, (ViewGroup) getActivity().findViewById(R.id.dialog_root));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(dialogLayout);
final AlertDialog alertDialog = builder.create();
LinearLayout layoutTypeOne = (LinearLayout) dialogLayout.findViewById(R.id.layout_one);
layoutTypeOne.setClickable(true);
RadioButton radioTypeOne = (RadioButton) dialogLayout.findViewById(R.id.radio_one);
LinearLayout layoutTypeTwo = (LinearLayout) dialogLayout.findViewById(R.id.layout_two);
layoutTypeTwo.setClickable(true);
RadioButton radioTypeTwo = (RadioButton) dialogLayout.findViewById(R.id.radio_two);
TextView done = (TextView) dialogLayout.findViewById(R.id.done);
radioTypeOne.setClickable(false);
radioTypeTwo.setClickable(false);
alertDialog.show();
switch(mSharedPreferenceUtil.getIconType()) {
case 0:
radioTypeOne.setChecked(true);
radioTypeTwo.setChecked(false);
break;
case 1:
radioTypeOne.setChecked(false);
radioTypeTwo.setChecked(true);
break;
}
layoutTypeOne.setOnClickListener(v -> {
radioTypeOne.setChecked(true);
radioTypeTwo.setChecked(false);
});
layoutTypeTwo.setOnClickListener(v -> {
radioTypeOne.setChecked(false);
radioTypeTwo.setChecked(true);
});
done.setOnClickListener(v -> {
mSharedPreferenceUtil.setIconType(radioTypeOne.isChecked() ? 0 : 1);
String[] iconsText = getResources().getStringArray(R.array.icons);
mChangeIcons.setSummary(radioTypeOne.isChecked() ? iconsText[0] : iconsText[1]);
alertDialog.dismiss();
Snackbar.make(getView(), "切换成功,重启应用生效", Snackbar.LENGTH_INDEFINITE).setAction("重启", v1 -> {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
getActivity().finish();
RxBus.getDefault().post(new ChangeCityEvent());
}).show();
});
}
use of android.widget.RadioButton in project iosched by google.
the class VideoLibraryFilteredFragment method updateRadioGroup.
/**
* Generates RadioButton for each item of the {@code values} list and adds them to the {@code
* radioGroup}. The item equals to {@code selectedValue} will be checked initially. Items with
* special Labels can be added using {@code specialValues}. They will be added on top and in
* uppercase characters.
*/
private <T extends Comparable> void updateRadioGroup(final RadioGroup radioGroup, List<T> values, T selectedValue, Map<T, String> specialValues) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (radioGroup == null) {
return;
}
// Add special Values to the list
List<T> specialItemsList = new ArrayList<>(specialValues.keySet());
Collections.sort(specialItemsList);
for (T keys : specialItemsList) {
values.add(0, keys);
}
radioGroup.removeAllViews();
radioGroup.clearCheck();
int idCounter = 0;
for (final T value : values) {
View buttonLayout = inflater.inflate(R.layout.video_library_filter_radio_button, radioGroup, false);
final RadioButton button = (RadioButton) buttonLayout.findViewById(R.id.button);
radioGroup.addView(buttonLayout);
// Set the Label of the Radio Button.
TextView text = (TextView) buttonLayout.findViewById(R.id.text);
text.setText(specialValues.get(value) == null ? value.toString() : specialValues.get(value));
// We have to give different IDs to all the RadioButtons inside the RadioGroup so that
// only one can be checked at a time.
button.setId(idCounter);
idCounter++;
// Trigger a RadioButton click when clicking the Text.
text.setOnClickListener(new View.OnClickListener() {
@Override
@TargetApi(15)
public void onClick(View v) {
button.callOnClick();
}
});
// When Clicking the RadioButton filter when re-filter the videos.
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
radioGroup.check(button.getId());
onVideoFilterChanged(value);
}
});
if (selectedValue.equals(value)) {
radioGroup.check(button.getId());
}
}
}
use of android.widget.RadioButton in project actor-platform by actorapp.
the class GroupTypeFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fragment_edit_type, container, false);
res.setBackgroundColor(style.getBackyardBackgroundColor());
TextView publicTitle = (TextView) res.findViewById(R.id.publicTitle);
publicTitle.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.group_public_channel_title : R.string.group_public_group_title);
publicTitle.setTextColor(style.getTextPrimaryColor());
TextView publicDescription = (TextView) res.findViewById(R.id.publicDescription);
publicDescription.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.group_public_channel_text : R.string.group_public_group_text);
publicDescription.setTextColor(style.getTextSecondaryColor());
TextView privateTitle = (TextView) res.findViewById(R.id.privateTitle);
privateTitle.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.group_private_channel_title : R.string.group_private_group_title);
privateTitle.setTextColor(style.getTextPrimaryColor());
TextView privateDescription = (TextView) res.findViewById(R.id.privateDescription);
privateDescription.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.group_private_channel_text : R.string.group_private_group_text);
privateDescription.setTextColor(style.getTextSecondaryColor());
TextView publicLinkPrefix = (TextView) res.findViewById(R.id.publicLinkPrefix);
publicLinkPrefix.setTextColor(style.getTextSecondaryColor());
String prefix = ActorSDK.sharedActor().getGroupInvitePrefix();
if (prefix == null) {
prefix = "@";
}
publicLinkPrefix.setText(prefix);
RadioButton publicRadio = (RadioButton) res.findViewById(R.id.publicRadio);
RadioButton privateRadio = (RadioButton) res.findViewById(R.id.privateRadio);
View publicSelector = res.findViewById(R.id.publicSelector);
View privateSelector = res.findViewById(R.id.privateSelector);
publicShortName = (EditText) res.findViewById(R.id.publicLink);
View publicLinkContainer = res.findViewById(R.id.publicContainer);
View publicShadowTop = res.findViewById(R.id.shadowTop);
View publicShadowBottom = res.findViewById(R.id.shadowBottom);
if (groupVM.getShortName().get() != null) {
publicRadio.setChecked(true);
privateRadio.setChecked(false);
publicLinkContainer.setVisibility(View.VISIBLE);
publicShadowTop.setVisibility(View.VISIBLE);
publicShadowBottom.setVisibility(View.VISIBLE);
publicShortName.setText(groupVM.getShortName().get());
isPublic = true;
} else {
publicRadio.setChecked(false);
privateRadio.setChecked(true);
publicLinkContainer.setVisibility(View.GONE);
publicShadowTop.setVisibility(View.GONE);
publicShadowBottom.setVisibility(View.GONE);
publicShortName.setText(null);
isPublic = false;
}
View.OnClickListener publicClick = view -> {
if (!isPublic) {
isPublic = true;
publicRadio.setChecked(true);
privateRadio.setChecked(false);
publicLinkContainer.setVisibility(View.VISIBLE);
publicShadowTop.setVisibility(View.VISIBLE);
publicShadowBottom.setVisibility(View.VISIBLE);
publicShortName.setText(groupVM.getShortName().get());
}
};
View.OnClickListener privateClick = view -> {
if (isPublic) {
isPublic = false;
publicRadio.setChecked(false);
privateRadio.setChecked(true);
publicLinkContainer.setVisibility(View.GONE);
publicShadowTop.setVisibility(View.GONE);
publicShadowBottom.setVisibility(View.GONE);
publicShortName.setText(null);
}
};
publicRadio.setOnClickListener(publicClick);
publicSelector.setOnClickListener(publicClick);
privateRadio.setOnClickListener(privateClick);
privateSelector.setOnClickListener(privateClick);
return res;
}
use of android.widget.RadioButton in project material-dialogs by afollestad.
the class DefaultRvAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(DefaultVH holder, int index) {
final View view = holder.itemView;
boolean disabled = DialogUtils.isIn(index, dialog.builder.disabledIndices);
switch(dialog.listType) {
case SINGLE:
{
@SuppressLint("CutPasteId") RadioButton radio = (RadioButton) holder.control;
boolean selected = dialog.builder.selectedIndex == index;
if (dialog.builder.choiceWidgetColor != null) {
MDTintHelper.setTint(radio, dialog.builder.choiceWidgetColor);
} else {
MDTintHelper.setTint(radio, dialog.builder.widgetColor);
}
radio.setChecked(selected);
radio.setEnabled(!disabled);
break;
}
case MULTI:
{
@SuppressLint("CutPasteId") CheckBox checkbox = (CheckBox) holder.control;
boolean selected = dialog.selectedIndicesList.contains(index);
if (dialog.builder.choiceWidgetColor != null) {
MDTintHelper.setTint(checkbox, dialog.builder.choiceWidgetColor);
} else {
MDTintHelper.setTint(checkbox, dialog.builder.widgetColor);
}
checkbox.setChecked(selected);
checkbox.setEnabled(!disabled);
break;
}
}
holder.title.setText(dialog.builder.items.get(index));
holder.title.setTextColor(dialog.builder.itemColor);
dialog.setTypeface(holder.title, dialog.builder.regularFont);
setupGravity((ViewGroup) view);
if (dialog.builder.itemIds != null) {
if (index < dialog.builder.itemIds.length) {
view.setId(dialog.builder.itemIds[index]);
} else {
view.setId(-1);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ViewGroup group = (ViewGroup) view;
if (group.getChildCount() == 2) {
// Remove circular selector from check boxes and radio buttons on Lollipop
if (group.getChildAt(0) instanceof CompoundButton) {
group.getChildAt(0).setBackground(null);
} else if (group.getChildAt(1) instanceof CompoundButton) {
group.getChildAt(1).setBackground(null);
}
}
}
}
Aggregations