clearCheck ( )源码实例Demo

android.widget.RadioGroup#clearCheck ( )源码实例Demo

下面列出了android.widget.RadioGroup#clearCheck ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android-discourse   文件: MainActivity.java
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);
}
 
源代码2 项目: mobile-android-survey-app   文件: GridFragment.java
@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);
}
 
源代码3 项目: itag   文件: SetNameDialogFragment.java
@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();
}
 
源代码4 项目: journaldev   文件: MainActivity.java
@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();
            }

        }
    });





}
 
源代码5 项目: AndroidAPS   文件: SWPlugin.java
@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);
}