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

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

源代码1 项目: MHViewer   文件: GalleryListScene.java
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();
        });
    }
}
 
源代码2 项目: AndroidDemo   文件: RecyclerViewScrollActivity.java
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);
}
 
源代码3 项目: android   文件: MainNormalActivity.java
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);
    }
}
 
源代码4 项目: SmsScheduler   文件: BuilderSimCard.java
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);
    }
}
 
源代码5 项目: fab   文件: FABActivity.java
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);
	}
}
 
源代码6 项目: fab   文件: FABActivity.java
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);
	}
}
 
源代码7 项目: sana.mobile   文件: RadioElement.java
/**
 * {@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);
}
 
源代码8 项目: prayer-times-android   文件: LanguageFragment.java
@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;
}
 
源代码9 项目: tuxguitar   文件: TGHarmonicDialog.java
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);
		}
	});
}
 
源代码10 项目: MHViewer   文件: FavoritesScene.java
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;
        });
    }
}
 
源代码11 项目: iGap-Android   文件: AdapterDialog.java
@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;
}
 
源代码12 项目: tuxguitar   文件: TGStrokeDialog.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);
}
 
源代码13 项目: tuxguitar   文件: TGMeasurePasteDialog.java
public void fillOption(int id, Integer value, boolean selected) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(selected);
}
 
源代码14 项目: tuxguitar   文件: TGMeasureAddDialog.java
public void fillOption(int id, Integer value, boolean selected) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(selected);
}
 
源代码15 项目: tuxguitar   文件: TGGraceDialog.java
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);
}
 
源代码16 项目: tuxguitar   文件: TGGraceDialog.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);
}
 
源代码17 项目: tuxguitar   文件: TGTripletFeelDialog.java
public void updateRadio(RadioButton button, Integer value, Integer selection) {
	button.setTag(Integer.valueOf(value));
	button.setChecked(selection != null && selection.equals(value));
}
 
源代码18 项目: tuxguitar   文件: TGGraceDialog.java
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);
}
 
源代码19 项目: tuxguitar   文件: TGTrillDialog.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);
}
 
源代码20 项目: 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);
}