Java Code Examples for android.widget.RadioGroup#clearCheck()

The following examples show how to use android.widget.RadioGroup#clearCheck() . 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: MainActivity.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
protected void siteChanged(RadioGroup group, int checkedId) {
    if (checkedId == -1) {
        return;
    }
    RadioButton button = (RadioButton) group.findViewById(checkedId);
    Site site = (Site) button.getTag();
    if (site != null) {
        App.setSiteUrl(site.getUrl());
    }
    if (site == null) {
        group.clearCheck();
        openSettingsActivity();
    } else if (!site.getUrl().equals(mCurrentSiteUrl)) { // TODO 第一次启动 加载上次查看的url。
        mDrawerPosition = ListView.INVALID_POSITION;
        mCurrentSite = site;
        mCurrentSiteUrl = site.getUrl();
        PrefsUtils.setCurrentSiteUrl(mCurrentSiteUrl);
        App.setLogin(false);
        clearDatabase();
        // 登陆完成后,再加载其他信息
        loadUserInfo(site, false);
    } else {
        setupUserInfo(mUser);
    }
    getActionBar().setSubtitle(mCurrentSiteUrl);
}
 
Example 2
Source File: GridFragment.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_clear) {
        for (int i = 0; i < gridContainer.getChildCount(); i++) {
            View view = gridContainer.getChildAt(i);
            if (view instanceof RadioGroup) {
                RadioGroup radioGroup = (RadioGroup)view;
                radioGroup.clearCheck();
            }
        }
    }
    return super.onOptionsItemSelected(item);
}
 
Example 3
Source File: SetNameDialogFragment.java    From itag with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final LayoutInflater inflater = Objects.requireNonNull(getActivity()).getLayoutInflater();
    @SuppressLint("InflateParams") final View view = inflater.inflate(R.layout.fragment_set_name, null);
    final TextView textName = view.findViewById(R.id.text_name);
    textName.setText(iTag.name());
    final RadioGroup grpAlarm = view.findViewById(R.id.alarm_delay);
    final RadioButton btnAlarm0 = view.findViewById(R.id.alarm_delay_0);
    final RadioButton btnAlarm3 = view.findViewById(R.id.alarm_delay_3);
    final RadioButton btnAlarm5 = view.findViewById(R.id.alarm_delay_5);
    final RadioButton btnAlarm10 = view.findViewById(R.id.alarm_delay_10);
    /*
    final AlarmDelayPreference alarmDelayPreference =
            new AlarmDelayPreference(this.getContext(), device);
            *
     */
    grpAlarm.clearCheck();
    int alarm =iTag.alertDelay();
    if (alarm<3) {
        btnAlarm0.setChecked(true);
    }else if (alarm < 5){
        btnAlarm3.setChecked(true);
    }else if (alarm <10) {
        btnAlarm5.setChecked(true);
    }else {
        btnAlarm10.setChecked(true);
    }

    builder.setTitle(R.string.change_name)
            .setView(view)
            .setPositiveButton(android.R.string.ok, (dialog, id) -> {
                ITag.store.setName(iTag.id(), textName.getText().toString());
                ITagApplication.faNameITag();
                switch (grpAlarm.getCheckedRadioButtonId()) {
                    case R.id.alarm_delay_0:
                        ITag.store.setAlertDelay(iTag.id(), 0);
                        break;
                    case R.id.alarm_delay_3:
                        ITag.store.setAlertDelay(iTag.id(), 3);
                        break;
                    case R.id.alarm_delay_5:
                        ITag.store.setAlertDelay(iTag.id(), 5);
                        break;
                    default:
                        ITag.store.setAlertDelay(iTag.id(), 10);
                        break;
                }
            })
            .setNegativeButton(android.R.string.cancel, (dialog, id) -> {
                //dialog.cancel();
            });
    return builder.create();
}
 
Example 4
Source File: MainActivity.java    From journaldev with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    radioGroup.clearCheck();

    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            RadioButton rb = (RadioButton) group.findViewById(checkedId);
            if (null != rb && checkedId > -1) {
                Toast.makeText(MainActivity.this, rb.getText(), Toast.LENGTH_SHORT).show();
            }

        }
    });





}
 
Example 5
Source File: SWPlugin.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void generateDialog(LinearLayout layout) {

    Context context = layout.getContext();
    radioGroup = new RadioGroup(context);
    radioGroup.clearCheck();

    ArrayList<PluginBase> pluginsInCategory = MainApp.getSpecificPluginsList(pType);

    radioGroup.setOrientation(LinearLayout.VERTICAL);
    radioGroup.setVisibility(View.VISIBLE);

    TextView pdesc = new TextView(context);
    pdesc.setText(pluginDescription);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 0, 40);
    pdesc.setLayoutParams(params);
    layout.addView(pdesc);

    for (int i = 0; i < pluginsInCategory.size(); i++) {
        RadioButton rdbtn = new RadioButton(context);
        PluginBase p = pluginsInCategory.get(i);
        rdbtn.setId(View.generateViewId());
        rdbtn.setText(p.getName());
        if (p.isEnabled(pType))
            rdbtn.setChecked(true);
        rdbtn.setTag(p);
        radioGroup.addView(rdbtn);
        params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(80, 0, 0, 0);
        TextView desc = new TextView(context);
        desc.setText(p.getDescription());
        desc.setLayoutParams(params);
        radioGroup.addView(desc);
    }

    radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        RadioButton rb = group.findViewById(checkedId);
        PluginBase plugin = (PluginBase) rb.getTag();
        plugin.setPluginEnabled(pType, rb.isChecked());
        plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
        ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
        ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
        RxBus.INSTANCE.send(new EventConfigBuilderChange());
        RxBus.INSTANCE.send(new EventSWUpdate(false));
    });
    layout.addView(radioGroup);
    super.generateDialog(layout);
}