android.widget.RadioButton#setChecked ( )源码实例Demo

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

源代码1 项目: ArchPackages   文件: SearchFragment.java
private void setUpKeywords() {
    RadioButton radioButtonNameOrDescription = radioGroupKeywords.findViewById(R.id.search_radio_button_name_or_description);
    RadioButton radioButtonExactName = radioGroupKeywords.findViewById(R.id.search_radio_button_exact_name);
    RadioButton radioButtonDescription = radioGroupKeywords.findViewById(R.id.search_radio_button_description);
    String sharedPreferenceKeywords = ArchPackagesSharedPreferences.getSharedPreferenceString(context,
            getString(R.string.key_keywords), getString(R.string.key_keywords_name_or_description));
    if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_name_or_description))) {
        radioButtonNameOrDescription.setChecked(true);
    } else if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_exact_name))) {
        radioButtonExactName.setChecked(true);
    } else if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_description))) {
        radioButtonDescription.setChecked(true);
    } else {
        radioButtonNameOrDescription.setChecked(true);
    }
}
 
源代码2 项目: owt-client-android   文件: SettingsFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View mView = inflater.inflate(R.layout.fragment_settings, container, false);
    cameraRG = mView.findViewById(R.id.camera_rg);
    cameraRG.setOnCheckedChangeListener(this);
    RadioButton frontCam = mView.findViewById(R.id.front);
    frontCam.setChecked(true);

    resolutionRG = mView.findViewById(R.id.resolution_rg);
    resolutionRG.setOnCheckedChangeListener(this);
    RadioButton vgaReso = mView.findViewById(R.id.vga);
    vgaReso.setChecked(true);

    return mView;
}
 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final View view = convertView != null ? convertView
            : mInflater.inflate(mTextViewResourceId, null);
    if (position < 0 || position >= mItemsList.size()) return view;
    final ImeSubtypeListItem item = mItemsList.get(position);
    final CharSequence imeName = item.mImeName;
    final CharSequence subtypeName = item.mSubtypeName;
    final TextView firstTextView = (TextView)view.findViewById(android.R.id.text1);
    final TextView secondTextView = (TextView)view.findViewById(android.R.id.text2);
    if (TextUtils.isEmpty(subtypeName)) {
        firstTextView.setText(imeName);
        secondTextView.setVisibility(View.GONE);
    } else {
        firstTextView.setText(subtypeName);
        secondTextView.setText(imeName);
        secondTextView.setVisibility(View.VISIBLE);
    }
    final RadioButton radioButton =
            (RadioButton)view.findViewById(com.android.internal.R.id.radio);
    radioButton.setChecked(position == mCheckedItem);
    return view;
}
 
源代码4 项目: emoji   文件: EmoticonView.java
public void init(Context mContext, OnEmoticonTapListener mTapListener, Resources resources) {
	this.mContext = mContext;
	this.mTapListener = mTapListener;
	this.resources = resources;
	parser = EmojiParser.getInstance(mContext);
	mEmojiGridView = (GridView) this.findViewById(R.id.message_facebar_gv_emotes);
	adapter = new EmojiAdapter();
	mEmojiGridView.setAdapter(adapter);
	mEmojiGridView.setOnItemClickListener(this);
	mEmojiGroup = (RadioGroup) findViewById(R.id.message_facebar_radiobutton_type);
	mEmojiGroup.setOnCheckedChangeListener(this);
	mEmojiRadio1 = (RadioButton) this.findViewById(R.id.emote_radio_1);
	mEmojiRadio1.setOnClickListener(this);
	mEmojiRadio1.setSelected(true);
	mEmojiRadio1.setChecked(true);
	mEmojiRadio2 = (RadioButton) this.findViewById(R.id.emote_radio_2);
	mEmojiRadio2.setOnClickListener(this);
	mEmojiRadio3 = (RadioButton) this.findViewById(R.id.emote_radio_3);
	mEmojiRadio3.setOnClickListener(this);
	mEmojiRadio4 = (RadioButton) this.findViewById(R.id.emote_radio_4);
	mEmojiRadio4.setOnClickListener(this);
	mEmojiRadio5 = (RadioButton) this.findViewById(R.id.emote_radio_5);
	mEmojiRadio5.setOnClickListener(this);
	mEmojiDelte = (ImageView) this.findViewById(R.id.emote_radio_delete);
	mEmojiDelte.setOnClickListener(this);
}
 
源代码5 项目: codeexamples-android   文件: MainActivity.java
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.button1:
            RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0);
            RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1);
            if (text.getText().length() == 0) {
                Toast.makeText(this, "Please enter a valid number",
                        Toast.LENGTH_LONG).show();
                return;
            }

            float inputValue = Float.parseFloat(text.getText().toString());
            if (celsiusButton.isChecked()) {
                text.setText(String
                        .valueOf(ConverterUtil.convertFahrenheitToCelsius(inputValue)));
                celsiusButton.setChecked(false);
                fahrenheitButton.setChecked(true);
            } else {
                text.setText(String
                        .valueOf(ConverterUtil.convertCelsiusToFahrenheit(inputValue)));
                fahrenheitButton.setChecked(false);
                celsiusButton.setChecked(true);
            }
            break;
    }
}
 
源代码6 项目: MvpRoute   文件: BannerView.java
@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;
}
 
源代码7 项目: Flubber   文件: BindingAdapters.java
@BindingAdapter({"checked", "model"})
public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) {

    if (checked == null) {
        return;
    }

    radioButton.setOnCheckedChangeListener(
            (buttonView, isChecked) -> {
                if ((checked.get() == null || !checked.get().equals(model))
                        && isChecked) {

                    checked.set(model);
                }
            });

    final T checkedModel = checked.get();
    final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model);

    if (shouldBeChecked != radioButton.isChecked()) {
        radioButton.setChecked(shouldBeChecked);
    }
}
 
源代码8 项目: friendly-plans   文件: TaskCreateFragment.java
private void registerViews(View view) {
    labelTaskName = (TextView) view.findViewById(R.id.id_tv_task_name_label);
    Utils.markFieldMandatory(labelTaskName);
    taskName = (EditText) view.findViewById(R.id.id_et_task_name);
    pictureFileName = (EditText) view.findViewById(R.id.id_et_task_picture);
    soundFileName = (EditText) view.findViewById(R.id.id_et_task_sound);
    taskDurationTime = (EditText) view.findViewById(R.id.id_et_task_duration_time);
    picturePreview = (ImageView) view.findViewById(R.id.iv_picture_preview);
    clearSound = (ImageButton) view.findViewById(R.id.id_ib_clear_sound_btn);
    clearPicture = (ImageButton) view.findViewById(R.id.id_ib_clear_img_btn);
    steps = (Button) view.findViewById(R.id.id_btn_steps);
    types = (RadioGroup) view.findViewById(R.id.id_rg_types);
    RadioButton typeTask = (RadioButton) view.findViewById(R.id.id_rb_type_task);
    typeTask.setChecked(true);
    taskType = TaskType.TASK;
}
 
源代码9 项目: MarketAndroidApp   文件: MenuDialogAdapter.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_item, null);
    }


    //绑定item内的TextView和RadioButton
    TextView nameText = MenuDialogAdapterViewHolder.get(convertView, R.id.menu_item_textview);
    RadioButton clickButton = MenuDialogAdapterViewHolder.get(convertView, R.id.radioButton);
    clickButton.setChecked(selectedPos == position);//改变点击选中状态

    //修改item高度,使其达到甲方要求的每页10个item显示要求
    ViewGroup.LayoutParams lp = nameText.getLayoutParams();
    lp.height = parent.getHeight() / 10;

    //获取选中的item的标题
    CommodityTypeModel menuData = menuDatas.get(position);
    String str = menuData.getName();
    nameText.setText(str);//设置标题

    convertView.setSelected(selectedPos == position);//设置选中时的view
    nameText.setSelected(selectedPos == position);//判断菜单的点击状态

    //选中后的标题字体及RadioButton颜色
    nameText.setTextColor(selectedPos == position ? 0xFF387ef5 : 0xFF222222);
    clickButton.setTextColor(selectedPos == position ? 0xFF787878 : 0xFF387ef5);

    return convertView;
}
 
源代码10 项目: masterpassword   文件: ExportDrawerItem.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View dialogView = View.inflate(getActivity(), R.layout.dialog_fileformat, null);
    final RadioButton jsonRadio = ButterKnife.findById(dialogView, R.id.radioButton_json);
    final RadioButton mpsitesRadio = ButterKnife
            .findById(dialogView, R.id.radioButton_mpsites);
    jsonRadio.setChecked(true);
    builder.setView(dialogView);
    builder.setTitle(R.string.title_exportFormat);
    builder.setNegativeButton(android.R.string.cancel, null);
    int okButtonTextResource = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            ? android.R.string.ok
            : R.string.caption_selectFolder;
    builder.setPositiveButton(okButtonTextResource, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Exporter exporter = new Exporter();
            ExportType exportType = ExportType.JSON;
            if (mpsitesRadio.isChecked()) {
                exportType = ExportType.MPSITES;
            }
            exporter.startExportIntent(getActivity(), exportType);
            dismiss();
        }
    });

    return builder.create();
}
 
源代码11 项目: Android-Keyboard   文件: RadioButtonPreference.java
@Override
protected void onBindView(final View view) {
    super.onBindView(view);
    mRadioButton = (RadioButton)view.findViewById(R.id.radio_button);
    mRadioButton.setChecked(mIsSelected);
    mRadioButton.setOnClickListener(mClickListener);
    view.setOnClickListener(mClickListener);
}
 
源代码12 项目: OmegaRecyclerView   文件: ExpandableActivity.java
protected void setupRadioButtons() {
    RadioButton dropdownRadioButton = findViewById(R.id.radiobutton_dropdown);
    RadioButton fadeRadioButton = findViewById(R.id.radiobutton_fade);
    RadioButton singleRadioButton = findViewById(R.id.radiobutton_single);
    RadioButton multipleRadioButton = findViewById(R.id.radiobutton_multiple);

    switch (mRecyclerView.getChildExpandAnimation()) {
        case OmegaExpandableRecyclerView.CHILD_ANIM_DROPDOWN:
            dropdownRadioButton.setChecked(true);
            break;
        case OmegaExpandableRecyclerView.CHILD_ANIM_FADE:
            fadeRadioButton.setChecked(true);
            break;
    }

    switch (mRecyclerView.getChildExpandAnimation()) {
        case OmegaExpandableRecyclerView.CHILD_ANIM_DROPDOWN:
            dropdownRadioButton.setChecked(true);
            break;
        case OmegaExpandableRecyclerView.CHILD_ANIM_FADE:
            fadeRadioButton.setChecked(true);
            break;
    }

    dropdownRadioButton.setOnCheckedChangeListener(this);
    fadeRadioButton.setOnCheckedChangeListener(this);
    singleRadioButton.setOnCheckedChangeListener(this);
    multipleRadioButton.setOnCheckedChangeListener(this);
}
 
源代码13 项目: java-n-IDE-for-Android   文件: LogFileAdapter.java
@NonNull
@Override
public View getView(int position, View view, @NonNull ViewGroup parent) {

    Context context = parent.getContext();

    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(resId, parent, false);
    }

    CheckBox box = (CheckBox) view.findViewById(android.R.id.checkbox);
    RadioButton button = (RadioButton) view.findViewById(android.R.id.button1);
    TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    TextView text2 = (TextView) view.findViewById(android.R.id.text2);

    CharSequence filename = objects.get(position);

    text1.setText(filename);


    if (multiMode) {
        box.setChecked(checkedItems[position]);
    } else {
        button.setChecked(checked == position);
    }

    Date lastModified = SaveLogHelper.getLastModifiedDate(filename.toString());
    DateFormat dateFormat = DateFormat.getDateTimeInstance();

    text2.setText(dateFormat.format(lastModified));

    return view;
}
 
源代码14 项目: commcare-android   文件: SelectOneWidget.java
@Override
public void clearAnswer() {
    for (RadioButton button : this.buttons) {
        if (button.isChecked()) {
            button.setChecked(false);
            break;
        }
    }
    clearButton.setVisibility(GONE);
}
 
源代码15 项目: commcare-android   文件: SelectOneWidget.java
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    onUserInteracton();
    if (isChecked) {
        for (RadioButton button : this.buttons) {
            if (button.isChecked() && !(buttonView == button)) {
                button.setChecked(false);
            }
        }
        clearButton.setVisibility(VISIBLE);
    }
    widgetEntryChanged();
}
 
源代码16 项目: leafpicrevived   文件: MapProviderSetting.java
public void choseProvider() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
    View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_map_provider, null);
    TextView dialogTitle = dialogLayout.findViewById(R.id.title);
    ((CardView) dialogLayout.findViewById(R.id.dialog_chose_provider_title)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
    dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());

    final RadioGroup mapProvider = dialogLayout.findViewById(R.id.radio_group_maps_provider);
    RadioButton radioGoogleMaps = dialogLayout.findViewById(R.id.radio_google_maps);
    RadioButton radioMapBoxStreets = dialogLayout.findViewById(R.id.radio_mapb_streets);
    RadioButton radioMapBoxDark = dialogLayout.findViewById(R.id.radio_mapb_dark);
    RadioButton radioMapBoxLight = dialogLayout.findViewById(R.id.radio_mapb_light);
    RadioButton radioTyler = dialogLayout.findViewById(R.id.radio_osm_tyler);

    getActivity().themeRadioButton(radioGoogleMaps);
    getActivity().themeRadioButton(radioMapBoxStreets);
    getActivity().themeRadioButton(radioMapBoxDark);
    getActivity().themeRadioButton(radioMapBoxLight);
    getActivity().themeRadioButton(radioTyler);

    ((TextView) dialogLayout.findViewById(R.id.header_proprietary_maps)).setTextColor(getActivity().getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.header_free_maps)).setTextColor(getActivity().getTextColor());
    switch (StaticMapProvider.fromValue(Hawk.get(getActivity().getString(R.string.preference_map_provider),
            StaticMapProvider.GOOGLE_MAPS.getValue()))) {
        case GOOGLE_MAPS:
        default:
            radioGoogleMaps.setChecked(true);
            break;
        case MAP_BOX:
            radioMapBoxStreets.setChecked(true);
            break;
        case MAP_BOX_DARK:
            radioMapBoxDark.setChecked(true);
            break;
        case MAP_BOX_LIGHT:
            radioMapBoxLight.setChecked(true);
            break;
        case TYLER:
            radioTyler.setChecked(true);
            break;
    }

    dialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), null);
    dialogBuilder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (mapProvider.getCheckedRadioButtonId()) {
                case R.id.radio_google_maps:
                default:
                    Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue());
                    break;
                case R.id.radio_mapb_streets:
                    Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX.getValue());
                    break;
                case R.id.radio_osm_tyler:
                    Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.TYLER.getValue());
                    break;
                case R.id.radio_mapb_dark:
                    Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX_DARK.getValue());
                    break;
                case R.id.radio_mapb_light:
                    Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX_LIGHT.getValue());
                    break;
            }
        }
    });
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.show();
}
 
源代码17 项目: tuxguitar   文件: TGGraceDialog.java
public void fillDynamic(int id, int value, int selection) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(value == selection);
}
 
源代码18 项目: tuxguitar   文件: TGTremoloPickingDialog.java
public void fillDuration(int id, int value, int selection) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(value == selection);
}
 
源代码19 项目: QNRTC-Android   文件: SettingActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    mUserNameEditText = (EditText) findViewById(R.id.user_name_edit_text);
    mConfigTextView = (TextView) findViewById(R.id.config_text_view);
    mVersionCodeTextView = (TextView) findViewById(R.id.version_code);
    mCodecModeRadioGroup = (RadioGroup) findViewById(R.id.codec_mode_button);
    mCodecModeRadioGroup.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mHwCodecMode = (RadioButton) findViewById(R.id.hw_radio_button);
    mSwCodecMode = (RadioButton) findViewById(R.id.sw_radio_button);
    mAudioSampleRateRadioGroup = findViewById(R.id.sample_rate_button);
    mAudioSampleRateRadioGroup.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mLowSampleRateBtn = findViewById(R.id.low_sample_rate_button);
    mHighSampleRateBtn = findViewById(R.id.high_sample_rate_button);

    mMaintainResRadioGroup = (RadioGroup) findViewById(R.id.maintain_resolution_button);
    mMaintainResRadioGroup.setOnCheckedChangeListener(mOnMaintainResCheckedChangeListener);
    mMaintainResolutionYes = (RadioButton) findViewById(R.id.maintain_res_button_yes);
    mMaintainResolutionNo = (RadioButton) findViewById(R.id.maintain_res_button_no);

    mAppIdEditText = (EditText) findViewById(R.id.app_id_edit_text);
    mAec3Switch = findViewById(R.id.webrtc_aec3_enable_btn);
    mAec3Switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mIsAec3Enabled = isChecked;
        }
    });

    mVersionCodeTextView.setText(String.format(getString(R.string.version_code), getVersionDescription(), getBuildTimeDescription()));

    SharedPreferences preferences = getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE);
    mUserName = preferences.getString(Config.USER_NAME, "");
    mUserNameEditText.setHint("用户名称:" + mUserName);
    String mAppId = preferences.getString(Config.APP_ID, QNAppServer.APP_ID);

    if (!mAppId.equals(QNAppServer.APP_ID)) {
        mAppIdEditText.setText(mAppId);
    }

    //test mode setting
    LinearLayout testModeLayout = (LinearLayout) findViewById(R.id.test_mode_layout);
    testModeLayout.setVisibility(isTestMode() ? View.VISIBLE : View.GONE);

    String[] configurations = getResources().getStringArray(R.array.conference_configuration);
    mDefaultConfiguration.addAll(Arrays.asList(configurations));

    mSelectPos = preferences.getInt(Config.CONFIG_POS, 1);
    mConfigTextView.setText(mDefaultConfiguration.get(mSelectPos));

    int codecMode = preferences.getInt(Config.CODEC_MODE, Config.HW);
    if (codecMode == Config.HW) {
        mHwCodecMode.setChecked(true);
    } else {
        mSwCodecMode.setChecked(true);
    }

    int sampleRatePos = preferences.getInt(Config.SAMPLE_RATE, Config.HIGH_SAMPLE_RATE);
    if (sampleRatePos == Config.LOW_SAMPLE_RATE) {
        mLowSampleRateBtn.setChecked(true);
    } else {
        mHighSampleRateBtn.setChecked(true);
    }

    mMaintainResolution = preferences.getBoolean(Config.MAINTAIN_RES, false);
    if (mMaintainResolution) {
        mMaintainResolutionYes.setChecked(true);
    } else {
        mMaintainResolutionNo.setChecked(true);
    }

    mIsAec3Enabled = preferences.getBoolean(Config.AEC3_ENABLE, false);
    mAec3Switch.setChecked(mIsAec3Enabled);

    mSpinnerPopupWindow = new SpinnerPopupWindow(this);
    mSpinnerPopupWindow.setOnSpinnerItemClickListener(mOnSpinnerItemClickListener);

    mAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, mDefaultConfiguration);
}
 
源代码20 项目: 365browser   文件: RadioButtonLayout.java
/**
 * Marks a RadioButton child as being checked.
 *
 * Android doesn't provide a way of generating View IDs on the fly before API level 17, so this
 * function requires passing in the child's index.  Passing in {@link #INVALID_INDEX} marks them
 * all as de-selected.
 *
 * @param childIndex Index of the child to select.
 */
public void selectChildAtIndex(int childIndex) {
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        RadioButton child = (RadioButton) getChildAt(i);
        child.setChecked(i == childIndex);
    }
}