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


Java RadioButton类代码示例

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


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

示例1: findSelectedDuration

import android.widget.RadioButton; //导入依赖的package包/类
public int findSelectedDuration(View view) {
	RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.stroke_dlg_duration_group);
	int radioButtonId = radioGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) radioGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return 0;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:12,代码来源:TGStrokeDialog.java

示例2: onChildViewAdded

import android.widget.RadioButton; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == RelativeRadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:mmb4rn0,项目名称:RelativeRadioGroup,代码行数:20,代码来源:RelativeRadioGroup.java

示例3: setTint

import android.widget.RadioButton; //导入依赖的package包/类
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            // Rdio button includes own alpha for disabled state
            ColorUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)),
            ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
        radioButton.setButtonDrawable(d);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:19,代码来源:TintHelper.java

示例4: findViews

import android.widget.RadioButton; //导入依赖的package包/类
private void findViews() {
    toolbar = (Toolbar) findViewById(R.id.air_toolbar);

    inputTitle = (TextInputEditText) findViewById(R.id.air_inputTitle);
    inputDescription = (TextInputEditText) findViewById(R.id.air_inputDescription);
    textDeviceInfo = (TextView) findViewById(R.id.air_textDeviceInfo);
    buttonDeviceInfo = (ImageButton) findViewById(R.id.air_buttonDeviceInfo);
    layoutDeviceInfo = (ExpandableRelativeLayout) findViewById(R.id.air_layoutDeviceInfo);

    inputUsername = (TextInputEditText) findViewById(R.id.air_inputUsername);
    inputPassword = (TextInputEditText) findViewById(R.id.air_inputPassword);
    inputEmail = (TextInputEditText) findViewById(R.id.air_inputEmail);
    optionUseAccount = (RadioButton) findViewById(R.id.air_optionUseAccount);
    optionAnonymous = (RadioButton) findViewById(R.id.air_optionAnonymous);
    layoutLogin = (ExpandableRelativeLayout) findViewById(R.id.air_layoutLogin);
    layoutAnonymous = (ExpandableRelativeLayout) findViewById(R.id.air_layoutGuest);

    buttonSend = (FloatingActionButton) findViewById(R.id.air_buttonSend);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:20,代码来源:AbstractIssueReporterActivity.java

示例5: onActivityCreated

import android.widget.RadioButton; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //noinspection ConstantConditions
    q2a1 = (RadioButton)getView().findViewById(R.id.question2);
    btn2 = (Button)getView().findViewById(R.id.submitans2);
    final SharedPreferences preferences = getActivity().getSharedPreferences("shared",0);
    btn2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            SharedPreferences.Editor editor = preferences.edit();
            if(q2a1.isChecked())
            {
                editor.putInt("ans2",1);
            }
            else {
                editor.putInt("ans2", 0);
            }
            editor.apply();
            ((QuizActivity)getActivity()).setCurrentItem(2,true);
        }
    });
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:25,代码来源:quiz2Fragment.java

示例6: ZenModeConditionSelection

import android.widget.RadioButton; //导入依赖的package包/类
public ZenModeConditionSelection(Context context, int zenMode) {
    super(context);
    mContext = context;
    mZenMode = zenMode;
    mConditions = new ArrayList<Condition>();
    setLayoutTransition(new LayoutTransition());
    final int p = mContext.getResources().getDimensionPixelSize(R.dimen.content_margin_left);
    setPadding(p, p, p, 0);
    mNoMan = INotificationManager.Stub.asInterface(
            ServiceManager.getService(Context.NOTIFICATION_SERVICE));
    final RadioButton b = newRadioButton(null);
    b.setText(mContext.getString(com.android.internal.R.string.zen_mode_forever));
    b.setChecked(true);
    for (int i = ZenModeConfig.MINUTE_BUCKETS.length - 1; i >= 0; --i) {
        handleCondition(ZenModeConfig.toTimeCondition(mContext,
                ZenModeConfig.MINUTE_BUCKETS[i], UserHandle.myUserId()));
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:19,代码来源:ZenModeConditionSelection.java

示例7: onViewCreated

import android.widget.RadioButton; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRadioGroup = (RadioGroup) view.findViewById(R.id.radio_group);
    mShowAllButton = (RadioButton) view.findViewById(R.id.show_all);
    mRedactSensitiveButton = (RadioButton) view.findViewById(R.id.redact_sensitive);

    mRadioGroup.setOnCheckedChangeListener(this);

    // Disable buttons according to policy.
    if (isSecureNotificationsDisabled(getActivity())) {
        mShowAllButton.setEnabled(false);
        mRedactSensitiveButton.setEnabled(false);
    } else if (isUnredactedNotificationsDisabled(getActivity())) {
        mShowAllButton.setEnabled(false);
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:18,代码来源:RedactionInterstitial.java

示例8: setTint

import android.widget.RadioButton; //导入依赖的package包/类
public static void setTint(@NonNull RadioButton radioButton,
                           @ColorInt int color) {
    final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    setTint(radioButton, sl);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MDTintHelper.java

示例9: initView

import android.widget.RadioButton; //导入依赖的package包/类
private void initView() {
    selectableTextView = (SelectableTextView) findViewById(R.id.ctv_content);
    selectableTextView.setText(Html.fromHtml(StringContentUtil.str_hanzi).toString());
    selectableTextView.clearFocus();
    selectableTextView.setTextJustify(true);
    selectableTextView.setForbiddenActionMenu(false);
    selectableTextView.setCustomActionMenuCallBack(this);
    selectableTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(HoriActivity.this, "SelectableTextView 的onClick事件", Toast.LENGTH_SHORT).show();
        }
    });

    rg_text_gravity = (RadioGroup) findViewById(R.id.rg_text_gravity);
    rg_text_content = (RadioGroup) findViewById(R.id.rg_text_content);
    ((RadioButton) findViewById(R.id.rb_justify)).setChecked(true);
    ((RadioButton) findViewById(R.id.rb_hanzi)).setChecked(true);
    rg_text_gravity.setOnCheckedChangeListener(this);
    rg_text_content.setOnCheckedChangeListener(this);
}
 
开发者ID:devilist,项目名称:AdvancedTextView,代码行数:22,代码来源:HoriActivity.java

示例10: onCreateDialog

import android.widget.RadioButton; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.fragment_send_schedule_dialog, null);

    setCurrentDateAndTime(view);

    builder.setCancelable(false);
    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(view);

    SegmentedGroup typeSG = (SegmentedGroup) view.findViewById(R.id.type_sg);
    distanceRadio = (RadioButton) view.findViewById(R.id.distance_radio);

    typeSG.setOnCheckedChangeListener(this);
    view.findViewById(R.id.schedule_positive_btn).setOnClickListener(this);
    view.findViewById(R.id.schedule_negative_btn).setOnClickListener(this);

    distanceRadio.performClick();
    dialog = builder.create();
    return dialog;
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:27,代码来源:RequestScheduleDialogFragment.java

示例11: setBezier3View

import android.widget.RadioButton; //导入依赖的package包/类
private void setBezier3View() {
    setContentView(R.layout.view_bezier_3);
    final Bezier3View bezier3View = (Bezier3View) findViewById(R.id.bezier_3_view);
    ((RadioButton) findViewById(R.id.control_1)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            bezier3View.setMode(isChecked);
        }
    });
   /* ((RadioButton) findViewById(R.id.control_2)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            bezier3View.setMode(false);
        }
    });*/
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:17,代码来源:MainActivity.java

示例12: onActivityCreated

import android.widget.RadioButton; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //noinspection ConstantConditions
    ans = (RadioButton)getView().findViewById(R.id.question6);
    submit = (Button)getView().findViewById(R.id.submitans6);
    final SharedPreferences preferences = getActivity().getSharedPreferences("shared",0);
    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            SharedPreferences.Editor editor = preferences.edit();
            if(ans.isChecked())
            {
                editor.putInt("ans6",1);
            }
            else {
                editor.putInt("ans6", 0);
            }
            editor.apply();
            ((QuizActivity)getActivity()).setCurrentItem(6,true);
        }
    });
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:25,代码来源:quiz6Fragment.java

示例13: buildNavViews

import android.widget.RadioButton; //导入依赖的package包/类
private void buildNavViews() {
    if (mAdapter == null)
        return;

    clearNavItems();
    isCursorWidthInited = false;

    for (int i = 0; i < mAdapter.getCount(); i++) {
        RadioButton item = mAdapter.getNavigatorButton(i, navButtonGroup);

        item.setId(i);
        item.setChecked(i == 0);

        navButtonGroup.addView(item, i);
    }

    navCursor = mAdapter.getCursor(navContainer);

    if (navCursor != null) {
        navContainer.addView(navCursor, 0);
    }
}
 
开发者ID:KaneJinCN,项目名称:android-CategoryPager,代码行数:23,代码来源:CategoryPagerNav.java

示例14: makeRadioButton

import android.widget.RadioButton; //导入依赖的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

示例15: getNavigatorButton

import android.widget.RadioButton; //导入依赖的package包/类
@Override
public RadioButton getNavigatorButton(int position, ViewGroup parent) {
    RadioButton rb = (RadioButton) LayoutInflater.from(mContext).inflate(R.layout.radio_btn_segmented, parent, false);

    if (position == 0) {
        rb.setBackgroundResource(R.drawable.segmented_control_first);
    } else if (position == getCount() - 1) {
        rb.setBackgroundResource(R.drawable.segmented_control_last);
    } else {
        rb.setBackgroundResource(R.drawable.segmented_control);
    }

    rb.setText(getPageTitle(position));

    return rb;

}
 
开发者ID:KaneJinCN,项目名称:android-CategoryPager,代码行数:18,代码来源:SegmentedControlAdapter.java


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