Java Code Examples for android.widget.RadioButton#setChecked()
The following examples show how to use
android.widget.RadioButton#setChecked() .
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: EmoticonView.java From emoji with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: TaskCreateFragment.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
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; }
Example 3
Source File: BindingAdapters.java From Flubber with Apache License 2.0 | 6 votes |
@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); } }
Example 4
Source File: BannerView.java From MvpRoute with Apache License 2.0 | 6 votes |
@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; }
Example 5
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
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; } }
Example 6
Source File: SearchFragment.java From ArchPackages with GNU General Public License v3.0 | 6 votes |
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); } }
Example 7
Source File: InputMethodManagerService.java From TvRemoteControl with Apache License 2.0 | 6 votes |
@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; }
Example 8
Source File: SettingsFragment.java From owt-client-android with Apache License 2.0 | 6 votes |
@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; }
Example 9
Source File: RadioButtonPreference.java From Android-Keyboard with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: ExpandableActivity.java From OmegaRecyclerView with MIT License | 5 votes |
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); }
Example 11
Source File: ExportDrawerItem.java From masterpassword with GNU General Public License v3.0 | 5 votes |
@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(); }
Example 12
Source File: LogFileAdapter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@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; }
Example 13
Source File: SelectOneWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void clearAnswer() { for (RadioButton button : this.buttons) { if (button.isChecked()) { button.setChecked(false); break; } } clearButton.setVisibility(GONE); }
Example 14
Source File: SelectOneWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@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(); }
Example 15
Source File: MenuDialogAdapter.java From MarketAndroidApp with Apache License 2.0 | 5 votes |
@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; }
Example 16
Source File: TGTremoloPickingDialog.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
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); }
Example 17
Source File: TGGraceDialog.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
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); }
Example 18
Source File: MapProviderSetting.java From leafpicrevived with GNU General Public License v3.0 | 4 votes |
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(); }
Example 19
Source File: SettingActivity.java From QNRTC-Android with Apache License 2.0 | 4 votes |
@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); }
Example 20
Source File: RadioButtonLayout.java From 365browser with Apache License 2.0 | 3 votes |
/** * 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); } }