当前位置: 首页>>代码示例>>Java>>正文


Java RadioGroup.addView方法代码示例

本文整理汇总了Java中android.widget.RadioGroup.addView方法的典型用法代码示例。如果您正苦于以下问题:Java RadioGroup.addView方法的具体用法?Java RadioGroup.addView怎么用?Java RadioGroup.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.RadioGroup的用法示例。


在下文中一共展示了RadioGroup.addView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeRadioButton

import android.widget.RadioGroup; //导入方法依赖的package包/类
private RadioButton makeRadioButton(RadioGroup baks, final String bk, final boolean item) {
    RadioButton bkb = new RadioButton(this);
    bkb.setText(bk);


    bkb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                selectedBackup = bk;
                selected = item;
                Log.d("backuppage", "selected = " + selectedBackup);
                backupSelected(selected);
            }
        }
    });

    baks.addView(bkb);
    return bkb;
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:21,代码来源:BackupActivity.java

示例2: setSingleSelectItems

import android.widget.RadioGroup; //导入方法依赖的package包/类
public void setSingleSelectItems(String[] singleSelectItems, int selectedItem, final OnClickListener onClickListener) {
    if (singleSelectItems != null && singleSelectItems.length > 0) {
        selectableItemsContainer.removeAllViews();
        selectableItemsContainer.setVisibility(View.VISIBLE);
        RadioGroup radioGroup = (RadioGroup) getLayoutInflater().inflate(R.layout.cfdialog_single_select_item_layout, selectableItemsContainer)
                                                                .findViewById(R.id.cfstage_single_select_radio_group);
        radioGroup.removeAllViews();
        for (int i = 0; i < singleSelectItems.length; i++) {
            String item = singleSelectItems[i];
            RadioButton radioButton = (RadioButton) getLayoutInflater().inflate(R.layout.cfdialog_single_select_radio_button_layout, null);
            radioButton.setText(item);
            radioButton.setId(i);
            final int position = i;
            if (position == selectedItem) {
                radioButton.setChecked(true);
            }
            radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked && onClickListener != null) {
                        onClickListener.onClick(CFAlertDialog.this, position);
                    }
                }
            });
            radioGroup.addView(radioButton);
        }
    } else {
        selectableItemsContainer.setVisibility(View.GONE);
    }
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:31,代码来源:CFAlertDialog.java

示例3: onCreateView

import android.widget.RadioGroup; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.welcome_account_fragment, container, false);
    if (mAccounts == null) {
        LOGD(TAG, "No accounts to display.");
        return null;
    }

    if (mActivity instanceof WelcomeFragmentContainer) {
        ((WelcomeFragmentContainer) mActivity).setPositiveButtonEnabled(false);
    }

    // Find the view
    RadioGroup accountsContainer = (RadioGroup) layout.findViewById(R.id.welcome_account_list);
    accountsContainer.removeAllViews();
    accountsContainer.setOnCheckedChangeListener(this);

    // Create the child views
    for (Account account : mAccounts) {
        LOGD(TAG, "Account: " + account.name);
        RadioButton button = new RadioButton(mActivity);
        button.setText(account.name);
        accountsContainer.addView(button);
    }

    return layout;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:32,代码来源:AccountFragment.java

示例4: getRadios

import android.widget.RadioGroup; //导入方法依赖的package包/类
private static View getRadios(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
    View view = inflater.inflate(R.layout.event_sign_up_radios, null);
    ((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(选填)") + ":");
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.rg_options);
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginEnd(100);
    if (!TextUtils.isEmpty(options.getOption())) {
        String[] list = options.getOption().split(";");
        String[] status = null;
        if (!TextUtils.isEmpty(options.getOptionStatus()))
            status = options.getOptionStatus().split(";");
        for (int i = 0; i < list.length; i++) {
            RadioButton button = new RadioButton(activity);
            button.setLayoutParams(params);
            button.setText(list[i]);
            if (!TextUtils.isEmpty(options.getDefaultValue())) {
                button.setChecked(list[0].equals(options.getDefaultValue()));
                options.setValue(options.getDefaultValue());
            } else {
                button.setChecked(i == 0);
                options.setValue(list[0]);
            }
            boolean enable;
            if (status == null)
                enable = true;
            else if (status.length <= i)
                enable = true;
            else
                enable = "0".equals(status[0]);
            button.setId(i);
            button.setEnabled(enable);
            radioGroup.addView(button);
        }
    }
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            String s[] = options.getOption().split(";");
            if (s != null)
                options.setValue(s[checkedId]);
        }
    });
    return view;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:47,代码来源:ViewFactory.java

示例5: initView

import android.widget.RadioGroup; //导入方法依赖的package包/类
private void initView() {
    final RadioGroup group = (RadioGroup) getView().findViewById(
            R.id.ringtoneGroup);

    RingtoneManager manager = new RingtoneManager(getActivity());
    manager.setType(RingtoneManager.TYPE_RINGTONE);
    int pdng = (int) (5 * getResources().getDisplayMetrics().density + .5f);
    final String[] columns = {MediaStore.Images.Media.DATA,
            MediaStore.Audio.Media._ID};
    final String orderBy = MediaStore.Images.Media._ID;
    Cursor imagecursor = getActivity().getContentResolver().query(
            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, null,
            null, orderBy);
    int dataColumnIndex = imagecursor
            .getColumnIndex(MediaStore.Audio.Media.DATA);
    for (int i = 0; i < imagecursor.getCount(); i++) {
        imagecursor.moveToPosition(i);
        final String uri = imagecursor.getString(dataColumnIndex);
        final String title = uri.substring(uri.lastIndexOf("/") + 1);
        RadioButton rb = new RadioButton(getActivity());
        rb.setLayoutParams(new RadioGroup.LayoutParams(
                RadioGroup.LayoutParams.MATCH_PARENT,
                RadioGroup.LayoutParams.WRAP_CONTENT));
        rb.setText(title);
        rb.setTypeface(((OneSheeldApplication) getActivity()
                .getApplication()).appFont);
        rb.setGravity(Gravity.CENTER);
        rb.setPadding(pdng, pdng, pdng, pdng);
        rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        rb.setTextColor(getResources().getColor(R.color.textColorOnDark));
        rb.setBackgroundResource(R.drawable.devices_list_item_selector);
        rb.setTag(uri);
        rb.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ((OneSheeldApplication) getActivity().getApplication())
                        .setBuzzerSound(uri);
            }
        });
        group.addView(rb);
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:44,代码来源:BuzzerShieldSettings.java

示例6: init

import android.widget.RadioGroup; //导入方法依赖的package包/类
private void init() {
	layoutSelectorView = activity.getLayoutInflater().inflate(R.layout.stream_layout_preview, null);
	final RadioGroup rg = (RadioGroup) layoutSelectorView.findViewById(R.id.layouts_radiogroup);
	final FrameLayout previewWrapper = (FrameLayout) layoutSelectorView.findViewById(R.id.preview_wrapper);

	if (previewMaxHeightRes != -1) {
		LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				(int) activity.getResources().getDimension(previewMaxHeightRes)
		);
		previewWrapper.setLayoutParams(lp);
		//previewWrapper.setMinimumHeight((int) activity.getResources().getDimension(previewMaxHeightRes));
	}

	ViewStub preview = (ViewStub) layoutSelectorView.findViewById(R.id.layout_stub);
	preview.setLayoutResource(previewLayout);
	final View inflated = preview.inflate();

	for (int i = 0; i < layoutTitles.length; i++) {
		final String layoutTitle = layoutTitles[i];

		final AppCompatRadioButton radioButton = new AppCompatRadioButton(activity);
		radioButton.setText(layoutTitle);

		final int finalI = i;
		radioButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				selectCallback.onSelected(layoutTitle, finalI, inflated);
			}
		});

		if (textColor != -1) {
			radioButton.setTextColor(Service.getColorAttribute(textColor, R.color.black_text, activity));

			ColorStateList colorStateList = new ColorStateList(
					new int[][]{
							new int[]{-android.R.attr.state_checked},
							new int[]{android.R.attr.state_checked}
					},
					new int[]{

							Color.GRAY, //Disabled
							Service.getColorAttribute(R.attr.colorAccent, R.color.accent, activity), //Enabled
					}
			);
			radioButton.setSupportButtonTintList(colorStateList);
		}


		radioButton.setLayoutParams(new ViewGroup.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT, // Width
				(int) activity.getResources().getDimension(R.dimen.layout_selector_height) // Height
		));


		rg.addView(radioButton, i);


		if ((selectedLayoutIndex != -1 && selectedLayoutIndex == i) || (selectedLayoutTitle != null && selectedLayoutTitle.equals(layoutTitle))) {
			radioButton.performClick();
		}
	}
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:65,代码来源:LayoutSelector.java


注:本文中的android.widget.RadioGroup.addView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。