Java Code Examples for android.widget.RadioGroup#OnCheckedChangeListener

The following examples show how to use android.widget.RadioGroup#OnCheckedChangeListener . 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: Activity_UpdateAddress.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
private void initView() {
    pg = new ProgressDialog(Activity_UpdateAddress.this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("添加地址");
    TextView toolbarText = (TextView) findViewById(R.id.toolbar_text);
    toolbarText.setText("");
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    findViewById();
    btn_submitAddress.setOnClickListener(this);
    //为radioGroup绑定监听器
    radioGroup.setOnCheckedChangeListener(changeListener);
    changeListener = new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            int id = group.getCheckedRadioButtonId();//获取选中按钮的id
            switch (id) {
                case R.id.rb_male://男
                    Toast.makeText(Activity_UpdateAddress.this, rb_male.getText(), Toast.LENGTH_SHORT).show();
                    Sex = "男";
                    break;
                case R.id.rb_female://女
                    Sex = "女";
                    break;
                default:
                    break;
            }
        }
    };

}
 
Example 2
Source File: FeedbackActivity.java    From zhizhihu with Apache License 2.0 5 votes vote down vote up
@NonNull
private FrameLayout createRadioGroupLayout(final String[] typeList, RadioGroup.OnCheckedChangeListener listener) {
    final List<RadioButton> rbList = new ArrayList<>();
    final RadioGroup radioGroup = new RadioGroup(this);
    radioGroup.setPadding(24, 24, 24, 24);
    for (int i = 0; i < typeList.length; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setText(typeList[i]);
        rbList.add(rb);
        radioGroup.addView(rb);
    }
    String curType = mFeedbackTypeTxt.getText().toString();
    for (RadioButton btn : rbList) {
        if (btn.getText().toString().equals(curType)) {
            radioGroup.check(btn.getId());
        }
    }
    radioGroup.setOnCheckedChangeListener(listener);
    FrameLayout frameLayout = new FrameLayout(this);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    lp.leftMargin = DimenUtil.dip2px(this, 24);
    lp.rightMargin = lp.leftMargin;
    frameLayout.addView(radioGroup, lp);
    return frameLayout;
}
 
Example 3
Source File: AdjustViewModel.java    From materialize with GNU General Public License v3.0 4 votes vote down vote up
@Bindable
public RadioGroup.OnCheckedChangeListener getShapeWatcher() {
    return (group, checkedId) -> setShape(mapShape(checkedId));
}
 
Example 4
Source File: AdjustViewModel.java    From materialize with GNU General Public License v3.0 4 votes vote down vote up
@Bindable
public RadioGroup.OnCheckedChangeListener getBackgroundWatcher() {
    return (group, checkedId) -> setBackground(mapColor(checkedId));
}
 
Example 5
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onCheckedChange(RadioGroup.OnCheckedChangeListener arg) {
  return BaseDSL.attr("onCheckedChange", arg);
}
 
Example 6
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onCheckedChange(RadioGroup.OnCheckedChangeListener arg) {
  return BaseDSL.attr("onCheckedChange", arg);
}
 
Example 7
Source File: WithSegmentedControlTextView.java    From BigApp_Discuz_Android with Apache License 2.0 2 votes vote down vote up
/**
 * 设置switchbutton 状态变更监听器
 *
 * @param onCheckedChangeListener
 */
public void setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener onCheckedChangeListener) {
    segmentedGroup.setOnCheckedChangeListener(onCheckedChangeListener);
}