Java Code Examples for android.widget.RadioButton#setTag()

The following examples show how to use android.widget.RadioButton#setTag() . 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: RecyclerViewScrollActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
private void initTab() {
    int padding = Tools.dip2px(this, 10);
    for (int i = 0; i < 20; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setPadding(padding, 0, padding, 0);
        rb.setButtonDrawable(null);
        rb.setGravity(Gravity.CENTER);
        rb.setTag(i * 5);
        rb.setText("Group " + i);
        rb.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        try {
            rb.setTextColor(getResources().getColorStateList(R.color.bg_tab_text));
        } catch (Exception e) {
            e.printStackTrace();
        }
        rb.setCompoundDrawablesWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.bg_block_tab));
        rb.setOnCheckedChangeListener(onCheckedChangeListener);
        rg_tab.addView(rb);
    }
    ((RadioButton) rg_tab.getChildAt(0)).setChecked(true);
}
 
Example 2
Source File: MainNormalActivity.java    From android with MIT License 6 votes vote down vote up
private void pairedBluetooth() {
    viewPairedDevices.removeAllViews();

    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    if (null != pairedDevices && pairedDevices.size() > 0) {
        StringBuilder msgBuilder = new StringBuilder();
        int index = 0;
        for (BluetoothDevice device : pairedDevices) {
            RadioButton radioButton = new RadioButton(this);
            radioButton.setId(index++);
            radioButton.setText(String.format("%s\n%s", device.getName(), device.getAddress()));
            radioButton.setTag(device);
            viewPairedDevices.addView(radioButton);

            msgBuilder.append(String.format("%s %s\n", device.getName(), device.getAddress()));
        }
        tvContent.setText(msgBuilder.toString());
        viewPairedDevices.setVisibility(View.VISIBLE);
    } else {
        viewPairedDevices.setVisibility(View.GONE);
    }
}
 
Example 3
Source File: GalleryListScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private void bindSource(ViewGroup parent) {
    LayoutInflater inflater = getLayoutInflater2();
    if (mFabLayout == null) {
        return;
    }

    if (inflater == null) {
        return;
    }

    for (MHPlugin source : MHPluginManager.Companion.getINSTANCE().livePlugin()) {
        RadioButton item = (RadioButton) inflater.inflate(R.layout.item_source_bar, parent, false);
        item.setText(source.getName().substring(0, 2));
        item.setTag(source.getName());
        item.setId(View.generateViewId());
        parent.addView(item);
        if (source.getName().equals(currentSource)) {
            item.setChecked(true);
        }
        item.setOnClickListener(v -> {
            switchSource((String) v.getTag());
            updateTopCategory();
            mHelper.refresh();
        });
    }
}
 
Example 4
Source File: BuilderSimCard.java    From SmsScheduler with GNU General Public License v2.0 5 votes vote down vote up
private void prepareRadioButton(RadioButton radioButton, Pair<Integer, String> simCard) {
    radioButton.setTag(simCard.first);
    radioButton.setText(simCard.second);
    radioButton.setOnClickListener(new RadioOnClickListener(sms));
    if (simCard.first.equals(sms.getSubscriptionId())) {
        radioButton.setChecked(true);
    }
}
 
Example 5
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void populateAnimationsRadioGroup(RadioGroup group, Set<RadioButtons.AnimationInfo> animationInfos) {
	for (RadioButtons.AnimationInfo animationInfo : animationInfos) {
		final RadioButton button = new RadioButton(this);
		final String text = getResources().getString(animationInfo.animationTextResId);
		button.setId(IdGenerator.next());
		button.setText(text);
		button.setTag(animationInfo);
		button.setEnabled(buttonBehaviorRadioGroup.getCheckedRadioButtonId() ==
				R.id.fab_activity_radiobutton_hide_and_show_on_click_radiobutton);
		group.addView(button);
	}
}
 
Example 6
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void populateColorsRadioGroup(RadioGroup group, Set<RadioButtons.ColorsInfo> colorsInfos) {
	for (RadioButtons.ColorsInfo colorsInfo : colorsInfos) {
		final RadioButton button = new RadioButton(this);
		final String text = getResources().getString(colorsInfo.colorTextResId);
		final int color = getResources().getColor(colorsInfo.primaryColorResId);
		final int textColor = color == getResources().getColor(R.color.fab_material_white) ?
				getResources().getColor(R.color.fab_material_black) : color;
		button.setId(IdGenerator.next());
		button.setText(text);
		button.setTextColor(textColor);
		button.setTag(colorsInfo);
		group.addView(button);
	}
}
 
Example 7
Source File: RadioElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    Log.i(TAG, "[" + id + "]createView()");
    ScrollView radioView = new ScrollView(c);
    mRadioGroup = new RadioGroup(c);
    mRadioGroup.setOrientation(LinearLayout.VERTICAL);
    rblist = new ArrayList<RadioButton>(values.length);

    if (answer == null)
        answer = "";
    for (String value : values) {
        Log.d(TAG, "..." + value + ":" + getLabelFromValue(value));
        RadioButton rb = new RadioButton(c);
        rb.setText(getLabelFromValue(value));
        rb.setTag(value);
        if (value.equals(answer)) {
            rb.setChecked(true);
        }
        rblist.add(rb);
        mRadioGroup.addView(rb);
    }
    mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            setAnswer(String.valueOf(group.findViewById(checkedId).getTag
                    ()));
        }
    });
    radioView.addView(mRadioGroup, new ViewGroup.LayoutParams(-1, -1));
    return encapsulateQuestion(c, radioView);
}
 
Example 8
Source File: TGHarmonicDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fillHarmonic(final int id, final int value, int selection, boolean enabled) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(value == selection);
	radioButton.setEnabled(enabled);
	radioButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			fillData(value, 0);
		}
	});
}
 
Example 9
Source File: LanguageFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.intro_language, container, false);
    RadioGroup radioGroup = v.findViewById(R.id.radioGroup);
    
    List<LocaleUtils.Translation> langs = LocaleUtils.getSupportedLanguages(getActivity());
    String currentLang = Preferences.LANGUAGE.get();
    int pos = 0;
    for (int i = 0; i < langs.size(); i++) {
        LocaleUtils.Translation lang = langs.get(i);
        if (lang.getLanguage().equals(currentLang))
            pos = i + 1;
        RadioButton button = new RadioButton(getContext());
        button.setTag(lang.getLanguage());
        button.setText(lang.getDisplayText());
        button.setTextColor(getResources().getColor(R.color.white));
        button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        int padding = (int) (button.getTextSize() / 2);
        button.setPadding(padding, padding, padding, padding);
        button.setOnCheckedChangeListener(this);
        radioGroup.addView(button);
    }
    if (pos != 0)
        ((RadioButton) radioGroup.getChildAt(pos)).setChecked(true);
    return v;
}
 
Example 10
Source File: TGMeasurePasteDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void fillOption(int id, Integer value, boolean selected) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(selected);
}
 
Example 11
Source File: TGTremoloPickingDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 12
Source File: TGTrillDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 13
Source File: TGGraceDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void fillTransition(int id, int value, int selection) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(value == selection);
}
 
Example 14
Source File: TGTripletFeelDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void updateRadio(RadioButton button, Integer value, Integer selection) {
	button.setTag(Integer.valueOf(value));
	button.setChecked(selection != null && selection.equals(value));
}
 
Example 15
Source File: TGGraceDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 16
Source File: TGGraceDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void fillOnBeatOption(int id, boolean value, boolean selection) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Boolean.valueOf(value));
	radioButton.setChecked(value == selection);
}
 
Example 17
Source File: TGMeasureAddDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void fillOption(int id, Integer value, boolean selected) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(selected);
}
 
Example 18
Source File: TGStrokeDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 19
Source File: AdapterDialog.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

    convertView = null;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.rg_adapter_dialog, null);
        name_tv = (RadioButton) convertView.findViewById(R.id.rg_radioButton);
        StructCountry structCountry = countrylist.get(position);
        name_tv.setText(structCountry.getName());
    }

    name_tv.setChecked(countrylist.get(position).getId() == mSelectedVariation);
    name_tv.setTag(position);
    name_tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            mSelectedVariation = (Integer) v.getTag();

            FragmentRegister.positionRadioButton = countrylist.get(position).getId();
            mSelectedVariation = countrylist.get(position).getId();
            notifyDataSetChanged();

            FragmentRegister.edtCodeNumber.setText(("+ " + countrylist.get(position).getCountryCode()));
            if (countrylist.get(position).getPhonePattern() != null || countrylist.get(position).getPhonePattern().equals(" ")) {
                FragmentRegister.edtPhoneNumber.setMask((countrylist.get(position).getPhonePattern().replace("X", "#").replace(" ", "-")));
            } else {
                FragmentRegister.edtPhoneNumber.setMaxLines(18);
                FragmentRegister.edtPhoneNumber.setMask("##################");
            }
            FragmentRegister.btnChoseCountry.setText((countrylist.get(position).getName()));
            FragmentRegisterViewModel.isoCode = countrylist.get(position).getAbbreviation();
            FragmentRegisterViewModel.btnOk.performClick();
            FragmentRegisterViewModel.dialogChooseCountry.dismiss();
        }
    });

    return convertView;
}
 
Example 20
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
private void bindSource(ViewGroup parent) {
    LayoutInflater inflater = getLayoutInflater2();
    if (mFabLayout == null) {
        return;
    }

    if (inflater == null) {
        return;
    }

    for (MHPlugin source : MHPluginManager.Companion.getINSTANCE().livePlugin()) {
        RadioButton item = (RadioButton) inflater.inflate(R.layout.item_source_bar, parent, false);
        item.setText(source.getName().substring(0, 2));
        item.setTag(source.getName());
        item.setId(View.generateViewId());
        parent.addView(item);
        if (source.getName().equals(currentSource)) {
            item.setChecked(true);
        }
        item.setOnClickListener(v -> {
            switchSource((String) v.getTag());
            mHelper.refresh();
            updateSearchBar();
        });

        item.setOnLongClickListener(v -> {
            String target = (String) v.getTag();
            new AlertDialog.Builder(getContext2())
                    .setTitle(getContext2().getResources().getString(R.string.import_collection, target, currentSource))
                    .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                        Intent intent = new Intent(getActivity2(), ImportService.class);
                        intent.setAction(ImportService.Companion.getACTION_START());
                        intent.putExtra(ImportService.Companion.getKEY_TARGET(), target);
                        intent.putExtra(ImportService.Companion.getKEY_SOURCE(), currentSource);
                        intent.putExtra(ImportService.Companion.getKEY_LOCAL(), mUrlBuilder.getFavCat() == FavListUrlBuilder.FAV_CAT_LOCAL);
                        getContext2().startService(intent);
                    }).create().show();
            return true;
        });
    }
}