Search in sources :

Example 96 with RadioButton

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);
}
Also used : RadioButton(android.widget.RadioButton) Before(org.junit.Before)

Example 97 with RadioButton

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();
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) SharedPreferenceUtil(com.xiecc.seeWeather.common.utils.SharedPreferenceUtil) RadioButton(android.widget.RadioButton) Watcher(com.hugo.watcher.Watcher) R(com.xiecc.seeWeather.R) BaseApplication(com.xiecc.seeWeather.base.BaseApplication) C(com.xiecc.seeWeather.common.C) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) SeekBar(android.widget.SeekBar) Locale(java.util.Locale) RxUtil(com.xiecc.seeWeather.common.utils.RxUtil) ImageLoader(com.xiecc.seeWeather.component.ImageLoader) View(android.view.View) Settings(android.provider.Settings) Observable(io.reactivex.Observable) Build(android.os.Build) RxBus(com.xiecc.seeWeather.component.RxBus) AutoUpdateService(com.xiecc.seeWeather.modules.service.AutoUpdateService) LayoutInflater(android.view.LayoutInflater) ChangeCityEvent(com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent) MainActivity(com.xiecc.seeWeather.modules.main.ui.MainActivity) ViewGroup(android.view.ViewGroup) File(java.io.File) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) FileUtil(com.xiecc.seeWeather.common.utils.FileUtil) Preference(android.preference.Preference) PreferenceFragment(android.preference.PreferenceFragment) Notification(android.app.Notification) Snackbar(android.support.design.widget.Snackbar) FileSizeUtil(com.xiecc.seeWeather.common.utils.FileSizeUtil) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) MainActivity(com.xiecc.seeWeather.modules.main.ui.MainActivity) ChangeCityEvent(com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent) View(android.view.View) TextView(android.widget.TextView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 98 with RadioButton

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());
        }
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) RadioButton(android.widget.RadioButton) View(android.view.View) UpdatableView(com.google.samples.apps.iosched.archframework.UpdatableView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 99 with RadioButton

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;
}
Also used : BaseFragment(im.actor.sdk.controllers.BaseFragment) ActorSDK(im.actor.sdk.ActorSDK) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) ActorSDKMessenger.messenger(im.actor.sdk.util.ActorSDKMessenger.messenger) RadioButton(android.widget.RadioButton) GroupVM(im.actor.core.viewmodel.GroupVM) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) R(im.actor.sdk.R) CreateGroupActivity(im.actor.sdk.controllers.compose.CreateGroupActivity) GroupUsersFragment(im.actor.sdk.controllers.compose.GroupUsersFragment) TextView(android.widget.TextView) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) View(android.view.View) Nullable(android.support.annotation.Nullable) EditText(android.widget.EditText) GroupType(im.actor.core.entity.GroupType) TextView(android.widget.TextView) RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 100 with RadioButton

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);
            }
        }
    }
}
Also used : CheckBox(android.widget.CheckBox) ViewGroup(android.view.ViewGroup) RadioButton(android.widget.RadioButton) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Aggregations

RadioButton (android.widget.RadioButton)198 View (android.view.View)100 TextView (android.widget.TextView)69 RadioGroup (android.widget.RadioGroup)43 Button (android.widget.Button)38 Intent (android.content.Intent)36 CheckBox (android.widget.CheckBox)28 EditText (android.widget.EditText)26 ImageView (android.widget.ImageView)21 CompoundButton (android.widget.CompoundButton)19 LayoutInflater (android.view.LayoutInflater)18 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)17 Bundle (android.os.Bundle)16 AdapterView (android.widget.AdapterView)15 DialogInterface (android.content.DialogInterface)14 Context (android.content.Context)10 ScrollView (android.widget.ScrollView)10 ArrayList (java.util.ArrayList)10 SharedPreferences (android.content.SharedPreferences)9