Java 类android.widget.RadioButton 实例源码

项目:RelativeRadioGroup    文件:RelativeRadioGroup.java   
/**
 * {@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);
    }
}
项目:tuxguitar    文件:TGStrokeDialog.java   
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;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:AbstractIssueReporterActivity.java   
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);
}
项目:CodeInPython    文件:quiz2Fragment.java   
@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);
        }
    });
}
项目:lineagex86    文件:ZenModeConditionSelection.java   
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()));
    }
}
项目:lineagex86    文件:RedactionInterstitial.java   
@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);
    }
}
项目:GitHub    文件:MDTintHelper.java   
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);
}
项目:AdvancedTextView    文件:HoriActivity.java   
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);
}
项目:Runnest    文件:RequestScheduleDialogFragment.java   
@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;
}
项目:Android-Code-Demos    文件:MainActivity.java   
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);
        }
    });*/
}
项目:CodeInPython    文件:quiz6Fragment.java   
@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);
        }
    });
}
项目:android-CategoryPager    文件:CategoryPagerNav.java   
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);
    }
}
项目:LaunchTime    文件:BackupActivity.java   
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;
}
项目:android-CategoryPager    文件:SegmentedControlAdapter.java   
@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;

}
项目:Android-SteamVR-controller    文件:WifiModeFragment.java   
@Override
public void onStop() {
    super.onStop();

    if (timer != null) {
        timer.cancel();
        timer = null;
    }

    targetIP = ipField.getText().toString();
    targetPort = Integer.parseInt(portField.getText().toString());
    RadioButton selectedButton = (RadioButton) view.findViewById(connectionModeToggleGroup.getCheckedRadioButtonId());
    connectionMode = WifiModeFragment.ConnectionModes.values()[connectionModeToggleGroup.indexOfChild(selectedButton)];
    sendInterval = Integer.parseInt(sendIntervalField.getText().toString());

    // Save preferences
    SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString(TARGET_IP_KEY, targetIP);
    editor.putInt(TARGET_PORT_KEY, targetPort);
    editor.putInt(CONNECTION_MODE_KEY, connectionMode.ordinal());
    editor.putLong(SEND_INTERVAL_KEY, sendInterval);
    editor.commit();
}
项目:MovingGdufe-Android    文件:MainActivity.java   
@OnClick({ R.id.rd_home, R.id.rd_features,R.id.rd_me }) public void onRadioButtonClicked(RadioButton radioButton) {
    boolean checked = radioButton.isChecked();
    switch (radioButton.getId()) {
        case R.id.rd_home:
            if (checked) {
                fUtil.show(mFragments.get(0));break;
            }
        case R.id.rd_features:
            if (checked) {
                fUtil.show(mFragments.get(1));break;
            }
        case R.id.rd_me:
            if (checked) {
                fUtil.show(mFragments.get(2));break;
            }
    }
}
项目:gst-android-camera    文件:CameraActivity.java   
public void onRadioButtonClicked(View view) {
    // Is the button now checked?
    boolean checked = ((RadioButton) view).isChecked();

    // Check which radio button was clicked
    switch(view.getId()) {
        case R.id.radio_resolution_320:
            if (checked) {
                gstAhc.changeResolutionTo(320, 240);
            }
            break;
        case R.id.radio_resolution_640:
            if (checked) {
                gstAhc.changeResolutionTo(640, 480);
            }
                break;
    }
}
项目:CodeInPython    文件:quiz7Fragment.java   
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //noinspection ConstantConditions
    ans = (RadioButton)getView().findViewById(R.id.question7);
    submit = (Button)getView().findViewById(R.id.submitans7);
    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("ans7",1);
            }
            else {
                editor.putInt("ans7", 0);
            }
            editor.apply();
            ((QuizActivity)getActivity()).setCurrentItem(7,true);
        }
    });
}
项目:Navigation-bar    文件:FlowRadioGroup.java   
/** 查找复合控件并设置radiobutton */
private void setCheckedView(ViewGroup vg) {
    int len = vg.getChildCount();
    for (int i = 0; i < len; i++) {
        if (vg.getChildAt(i) instanceof RadioButton) {// 如果找到了,就设置check状态
            final RadioButton button = (RadioButton) vg.getChildAt(i);
            // 添加到容器
            radioButtons.add(button);
            if (button.isChecked()) {
                mProtectFromCheckedChange = true;
                if (mCheckedId != -1) {
                    setCheckedStateForView(mCheckedId, false);
                }
                mProtectFromCheckedChange = false;
                setCheckedId(button.getId());
            }
        } else if (vg.getChildAt(i) instanceof ViewGroup) {// 迭代查找并设置
            ViewGroup childVg = (ViewGroup) vg.getChildAt(i);
            setCheckedView(childVg);
        }
    }
}
项目:Navigation-bar    文件:FlowRadioGroup.java   
/** 查找复合控件并设置id */
private void setCheckedId(ViewGroup vg) {
    int len = vg.getChildCount();
    for (int i = 0; i < len; i++) {
        if (vg.getChildAt(i) instanceof RadioButton) {// 如果找到了,就设置check状态
            final RadioButton button = (RadioButton) vg.getChildAt(i);
            int id = button.getId();
            // generates an id if it's missing
            if (id == View.NO_ID) {
                id = button.hashCode();
                button.setId(id);
            }
            button.setOnCheckedChangeListener(mChildOnCheckedChangeListener);
        } else if (vg.getChildAt(i) instanceof ViewGroup) {// 迭代查找并设置
            ViewGroup childVg = (ViewGroup) vg.getChildAt(i);
            setCheckedId(childVg);
        }
    }
}
项目:reflow-animator    文件:AdvancedOptionsDialogFragment.java   
@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end })
void onTargetAlignmentChanged(RadioButton button, boolean isChecked) {
    if (isChecked) {
        int alignment = Gravity.NO_GRAVITY;
        switch (button.getId()) {
            case R.id.target_align_start:
                alignment = Gravity.START;
                break;
            case R.id.target_align_center:
                alignment = Gravity.CENTER_HORIZONTAL;
                break;
            case R.id.target_align_end:
                alignment = Gravity.END;
                break;
        }
        onUpdateListener.updateTargetTextAlignment(alignment);
    }
}
项目:boohee_v5.6    文件:ChangeEnvironmentActivity$$ViewInjector.java   
public void inject(Finder finder, T target, Object source) {
    target.tvPhone = (TextView) finder.castView((View) finder.findRequiredView(source, R.id
            .tv_phone, "field 'tvPhone'"), R.id.tv_phone, "field 'tvPhone'");
    target.tvNetState = (TextView) finder.castView((View) finder.findRequiredView(source, R
            .id.tv_net_state, "field 'tvNetState'"), R.id.tv_net_state, "field 'tvNetState'");
    target.tvIpState = (TextView) finder.castView((View) finder.findRequiredView(source, R.id
            .tv_ip_state, "field 'tvIpState'"), R.id.tv_ip_state, "field 'tvIpState'");
    target.rbQA = (RadioButton) finder.castView((View) finder.findRequiredView(source, R.id
            .rb_qa, "field 'rbQA'"), R.id.rb_qa, "field 'rbQA'");
    target.rbRC = (RadioButton) finder.castView((View) finder.findRequiredView(source, R.id
            .rb_rc, "field 'rbRC'"), R.id.rb_rc, "field 'rbRC'");
    target.rbPRO = (RadioButton) finder.castView((View) finder.findRequiredView(source, R.id
            .rb_pro, "field 'rbPRO'"), R.id.rb_pro, "field 'rbPRO'");
    target.rgEnvironment = (RadioGroup) finder.castView((View) finder.findRequiredView
            (source, R.id.rg_environment, "field 'rgEnvironment'"), R.id.rg_environment,
            "field 'rgEnvironment'");
    target.cbIPConnect = (CheckBox) finder.castView((View) finder.findRequiredView(source, R
            .id.cb_ip_connect, "field 'cbIPConnect'"), R.id.cb_ip_connect, "field " +
            "'cbIPConnect'");
    target.tvConnectIPs = (TextView) finder.castView((View) finder.findRequiredView(source, R
            .id.tv_connect_ips, "field 'tvConnectIPs'"), R.id.tv_connect_ips, "field " +
            "'tvConnectIPs'");
    target.tvDns = (TextView) finder.castView((View) finder.findRequiredView(source, R.id
            .tv_dns, "field 'tvDns'"), R.id.tv_dns, "field 'tvDns'");
}
项目:Beach-Android    文件:PollResponseActivity.java   
private void initView() {
    pollId = getIntent().getLongExtra("pollId", 0);
    content = DbManager.getInstance().getPollDetails(pollId);

    ivBack = (ImageView) findViewById(R.id.ivBack);
    ivNext = (ImageView) findViewById(R.id.ivNext);
    tvHeader = (TextView) findViewById(R.id.tvHeader);
    ivNext.setVisibility(View.INVISIBLE);
    tvHeader.setText("Poll Response");

    tvExpiryTime = (TextView) findViewById(R.id.tvExpiryTime);
    tvPollQuestion = (TextView) findViewById(R.id.tvPollQuestion);
    tvOptionOne = (TextView) findViewById(R.id.tvOptionOne);
    tvOptionTwo = (TextView) findViewById(R.id.tvOptionTwo);
    tvOptionThree = (TextView) findViewById(R.id.tvOptionThree);
    tvOptionFour = (TextView) findViewById(R.id.tvOptionFour);
    btnRespond = (Button) findViewById(R.id.btnRespond);
    llOptions= (LinearLayout) findViewById(R.id.llOptions);
    llCheckbox = (LinearLayout) findViewById(R.id.llCheckbox);
    llRadioButton = (LinearLayout) findViewById(R.id.llRadioButton);
    rgOptions = (RadioGroup) findViewById(R.id.rgOptions);
    rdOptionOne = (RadioButton) findViewById(R.id.rdOptionOne);
    rdOptionTwo = (RadioButton) findViewById(R.id.rdOptionTwo);
    rdOptionThree = (RadioButton) findViewById(R.id.rdOptionThree);
    rdOptionFour = (RadioButton) findViewById(R.id.rdOptionFour);
    cbOptionOne = (CheckBox) findViewById(R.id.cbOptionOne);
    cbOptionTwo = (CheckBox) findViewById(R.id.cbOptionTwo);
    cbOptionThree = (CheckBox) findViewById(R.id.cbOptionThree);
    cbOptionFour = (CheckBox) findViewById(R.id.cbOptionFour);
    tvYourResponse = (TextView) findViewById(R.id.tvYourResponse);
    etDescriptive = (EditText) findViewById(R.id.etDescriptive);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
}
项目:RelativeRadioGroup    文件:RelativeRadioGroup.java   
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (child instanceof RadioButton) {
        final RadioButton button = (RadioButton) child;
        if (button.isChecked()) {
            mProtectFromCheckedChange = true;
            if (mCheckedId != -1) {
                setCheckedStateForView(mCheckedId, false);
            }
            mProtectFromCheckedChange = false;
            setCheckedId(button.getId());
        }
    }

    super.addView(child, index, params);
}
项目:aos-Video    文件:ModeSwitchDialog.java   
public Dialog createDialog() {
    View root = LayoutInflater.from(getContext()).inflate(R.layout.cast_mode_dialog, null);
    mStreamButton = (RadioButton) root.findViewById(R.id.cast_stream_button);
    mRadioGroup = (RadioGroup)root.findViewById(R.id.radio_group);

    mRemoteDisplayButton = (RadioButton) root.findViewById(R.id.cast_remote_button);
    if(ArchosVideoCastManager.getInstance().isRemoteDisplayConnected())
        mRemoteDisplayButton.setChecked(true);
    else
        mStreamButton.setChecked(true);
    mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            if(i==R.id.cast_stream_button)
                ArchosVideoCastManager.getInstance().switchToVideoCast();
            else
                ArchosVideoCastManager.getInstance().switchToDisplayCast();
            mDialog.dismiss();
        }
    });
    mDialog = new AlertDialog.Builder(getContext()).setView(root).create();
    return mDialog;
}
项目:MetadataEditor    文件:TintHelper.java   
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);
    }
}
项目:Tusky    文件:ComposeOptionsFragment.java   
private static void setRadioButtonDrawable(Context context, RadioButton button,
                                           @DrawableRes int id) {
    ColorStateList list = new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_checked },
            new int[] { android.R.attr.state_checked }
    }, new int[] {
            ThemeUtils.getColor(context, R.attr.compose_image_button_tint),
            ThemeUtils.getColor(context, R.attr.colorAccent)
    });
    Drawable drawable = VectorDrawableCompat.create(context.getResources(), id,
            context.getTheme());
    if (drawable == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        button.setButtonTintList(list);
    } else {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable, list);
    }
    button.setButtonDrawable(drawable);
}
项目:lineagex86    文件:ZenModeConditionSelection.java   
private RadioButton newRadioButton(Condition condition) {
    final RadioButton button = new RadioButton(mContext);
    button.setTag(condition);
    button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setCondition((Condition) button.getTag());
            }
        }
    });
    addView(button);
    return button;
}
项目:CXJPadProject    文件:TestItemView.java   
private void initCheckGroup(final OrderTestModel.OrderItemCheckListBean model, LayoutInflater inflater) {
        for (int z = 0; z < model.checkItemSuggestions.size(); z++) {
            final OrderTestModel.OrderItemCheckListBean.CheckItemSuggestionsBean item = model.checkItemSuggestions.get(z);
//            final RadioButton ckview = (RadioButton)inflater.inflate(R.layout.fragment_test_item_ck, null);
            final RadioButton ckview = new RadioButton(activity);
            ckview.setText(item.suggestionOption);
            if (item.isChecked.equals("1")) {
                checkId = item.checkItemSuggestionsId;
                ckview.setChecked(true);
            } else {
                ckview.setChecked(false);
            }
            ckview.setTag(item.checkItemSuggestionsId);
            ckview.setTextColor(this.getResources().getColor(R.color.gray_text));
            ckview.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT));
            ckview.setTextSize(18);
            ckview.setId(z);
            ckview.setPadding(2, 0, 12, 0);
            ckview.setGravity(Gravity.CENTER | left);
            Drawable drawable = getResources().getDrawable(
                    R.drawable.checkbox_selector_circle_bac);
            // 这一步必须要做,否则不会显示.
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                    drawable.getMinimumHeight());
            ckview.setCompoundDrawables(drawable, null, null, null);
            ckview.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkId = (String) ckview.getTag();
                }
            });
            llsugestcontain.addView(ckview);
        }
    }
项目:OSchina_resources_android    文件:DialogAdapter.java   
@Override
public View getView(int i, View view, ViewGroup viewgroup) {
    DialogHolder vh = null;
    if (view == null) {
        vh = new DialogHolder();
        view = LayoutInflater.from(viewgroup.getContext()).inflate(
                R.layout.list_cell_dialog, null, false);
        vh.titleTv = (TextView) view.findViewById(R.id.title_tv);
        vh.divider = view.findViewById(R.id.list_divider);
        vh.checkIv = (RadioButton) view.findViewById(R.id.rb_select);
        view.setTag(vh);
    } else {
        vh = (DialogHolder) view.getTag();
    }
    vh.titleTv.setText(getItem(i));

    if (i == -1 + getCount()) {
        vh.divider.setVisibility(View.GONE);
    } else {
        vh.divider.setVisibility(View.VISIBLE);
    }

    if (showChk) {
        vh.checkIv.setVisibility(View.VISIBLE);
        if (select == i) {
            vh.checkIv.setChecked(true);
        } else {
            vh.checkIv.setChecked(false);
        }
    } else {
        vh.checkIv.setVisibility(View.GONE);
    }
    return view;
}
项目:GitHub    文件:MDTintHelper.java   
public static void setTint(@NonNull RadioButton radioButton,
                           @NonNull ColorStateList colors) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(colors);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(),
                R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, colors);
        radioButton.setButtonDrawable(d);
    }
}
项目:GitHub    文件:MultitaskTestActivity.java   
private void assignViews() {
    taskCountSb = (SeekBar) findViewById(R.id.task_count_sb);
    taskCountTv = (TextView) findViewById(R.id.task_count_tv);
    timeConsumeTv = (TextView) findViewById(R.id.time_consume_tv);
    wayRgp = (RadioGroup) findViewById(R.id.way_rgp);
    serialRbtn = (RadioButton) findViewById(R.id.serial_rbtn);
    parallelRbtn = (RadioButton) findViewById(R.id.parallel_rbtn);
    avoidMissFrameCb = (CheckBox) findViewById(R.id.avoid_miss_frame_cb);
    overTaskPb = (ProgressBar) findViewById(R.id.over_task_pb);
    actionBtn = (Button) findViewById(R.id.action_btn);
    pendingTv = (TextView) findViewById(R.id.pending_tv);
    pendingInfoTv = (TextView) findViewById(R.id.pending_info_tv);
    pendingPb = (ProgressBar) findViewById(R.id.pending_pb);
    connectedTv = (TextView) findViewById(R.id.connected_tv);
    connectedInfoTv = (TextView) findViewById(R.id.connected_info_tv);
    connectedPb = (ProgressBar) findViewById(R.id.connected_pb);
    progressTv = (TextView) findViewById(R.id.progress_tv);
    progressInfoTv = (TextView) findViewById(R.id.progress_info_tv);
    progressPb = (ProgressBar) findViewById(R.id.progress_pb);
    retryTv = (TextView) findViewById(R.id.retry_tv);
    retryInfoTv = (TextView) findViewById(R.id.retry_info_tv);
    retryPb = (ProgressBar) findViewById(R.id.retry_pb);
    errorTv = (TextView) findViewById(R.id.error_tv);
    errorInfoTv = (TextView) findViewById(R.id.error_info_tv);
    errorPb = (ProgressBar) findViewById(R.id.error_pb);
    pausedTv = (TextView) findViewById(R.id.paused_tv);
    pausedInfoTv = (TextView) findViewById(R.id.paused_info_tv);
    pausedPb = (ProgressBar) findViewById(R.id.paused_pb);
    completedReusedTv = (TextView) findViewById(R.id.completed_with_old_tv);
    completedReusedInfoTv = (TextView) findViewById(R.id.completed_with_old_info_tv);
    completedReusedPb = (ProgressBar) findViewById(R.id.completed_with_old_pb);
    completedDownloadingTv = (TextView) findViewById(R.id.completed_tv);
    completedDownloadingInfoTv = (TextView) findViewById(R.id.completed_info_tv);
    completedDownloadingPb = (ProgressBar) findViewById(R.id.completed_pb);
    warnTv = (TextView) findViewById(R.id.warn_tv);
    warnInfoTv = (TextView) findViewById(R.id.warn_info_tv);
    warnPb = (ProgressBar) findViewById(R.id.warn_pb);
    deleteAllFileBtn = (Button) findViewById(R.id.delete_all_file_btn);
}
项目:Android-Client    文件:CreateFilterActivity2.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_filter_activity_2);
    setTitle("Create Filter");

    String filterValue = getIntent().getStringExtra(FILTER_CATEGORY_KEY);
    filter = Filter.fromNetworkString(filterValue);
    interests = filter.getInterests();

    /*
     * Get view references
     */
    iconImageView = (ImageView) findViewById(R.id.filter_activity_2_image);
    titleTextView = (TextView) findViewById(R.id.filter_activity_2_title);

    permanentRadioButton = (RadioButton) findViewById(R.id.filter_activity_2_permanent_radio);
    oneHourRadioButton = (RadioButton) findViewById(R.id.filter_activity_2_time_limit_radio);
    maleRadioButton = (RadioButton) findViewById(R.id.filter_activity_2_male_radiobutton);
    femaleRadioButton = (RadioButton) findViewById(R.id.filter_activity_2_female_radiobutton);

    interestsRecyclerView = (RecyclerView) findViewById(R.id.create_filter_2_recycler_view);

    /*
     * Set view data
     */
    iconImageView.setBackgroundResource(filter.getIconId());
    titleTextView.setText(filter.getDisplayString());

    interestsRecyclerView.setAdapter(createAdapter());
}
项目:TabPager    文件:NavView.java   
/**
 * 设置Tab样式
 *
 * @param rb      Tab项
 * @param checked 是否选中
 */
private void setTabStyle(RadioButton rb, boolean checked) {
    if (checked) {
        rb.setTextColor(mNavTextCheckedColor);
        if (null == mNavBgCheckedImg) {
            rb.setBackgroundColor(mNavBgCheckedColor);
        } else {
            rb.setBackgroundDrawable(mNavBgCheckedImg);
        }
    } else {
        rb.setTextColor(mNavTextDefaultColor);
        rb.setBackgroundColor(Color.TRANSPARENT);
        rb.setBackgroundDrawable(null);
    }
}
项目:IT405    文件:MainActivity.java   
/**
 *  locateViews - Used to fetch the views from the layout (since findViewById is an expensive
 *  function to call multiple times)
 */
private void locateViews(){
    button = (Button) findViewById(R.id.button);
    toggleButton = (ToggleButton) findViewById(R.id.toggleButton);
    radioButton = (RadioButton) findViewById(R.id.radioButton);
    imageButton = (ImageButton) findViewById(R.id.imageButton);
    checkBox = (CheckBox) findViewById(R.id.checkBox);
}
项目:OpenHomeAnalysis    文件:OhaEnergyUseWhHolder.java   
public OhaEnergyUseWhHolder(View itemView) {
    super(itemView);
    this.radioButtonHour = (RadioButton) itemView.findViewById(R.id.radioButtonHour);
    this.textViewHour = (TextView) itemView.findViewById(R.id.textViewHour);
    this.textViewDuration = (TextView) itemView.findViewById(R.id.textViewDuration);
    this.textViewWh1 = (TextView) itemView.findViewById(R.id.textViewWh1);
    this.textViewWh2 = (TextView) itemView.findViewById(R.id.textViewWh2);
    this.textViewWh3 = (TextView) itemView.findViewById(R.id.textViewWh3);
    this.textViewKwh = (TextView) itemView.findViewById(R.id.textViewKwh);
    this.textViewCost = (TextView) itemView.findViewById(R.id.textViewCost);
}
项目:MeiLa_GNN    文件:FragmentTabUtils.java   
public FragmentTabUtils(FragmentManager fragmentManager, List<Fragment> fragments, int fragmentContentId, RadioGroup rgs, OnRgsExtraCheckedChangedListener onRgsExtraCheckedChangedListener) {
    this.fragments = fragments;
    this.rgs = rgs;
    this.fragmentManager = fragmentManager;
    this.fragmentContentId = fragmentContentId;
    this.onRgsExtraCheckedChangedListener = onRgsExtraCheckedChangedListener;
    rgs.setOnCheckedChangeListener(this);
    ((RadioButton) rgs.getChildAt(0)).setChecked(true);
}
项目:RNLearn_Project1    文件:AccessibilityHelper.java   
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
  super.onInitializeAccessibilityNodeInfo(host, info);
  info.setClassName(RadioButton.class.getName());
  info.setCheckable(true);
  info.setChecked(false);
}
项目:AddressChecker    文件:AddressListAdapter.java   
AddressViewHolder(View itemView) {
    super(itemView);
    mTvAddress = (TextView) itemView.findViewById(R.id.tv_area_name);
    mRadioButton = (RadioButton) itemView.findViewById(R.id.radio_btn);

    itemView.setOnClickListener(this);
}
项目:Neuronizer    文件:TodoListAppWidgetConfigure.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);
    setContentView(R.layout.activity_widget_configure);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    repositoryName = sharedPreferences.getString(KEY_PREF_ACTIVE_REPO, FALLBACK_REALM);
    List<TodoList> list = new TodoListRepositoryImpl(repositoryName).getAll();

    radioGroup = findViewById(R.id.widget_config_radio_group);
    todoLists = list.toArray(new TodoList[list.size()]);
    radioButtons = new RadioButton[todoLists.length];
    createRadioButtons();
}