當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。