Java Code Examples for android.widget.RadioButton

The following are top voted examples for showing how to use android.widget.RadioButton. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: tuxguitar   File: TGStrokeDialog.java   View source code 9 votes vote down vote up
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;
}
 
Example 2
Project: RelativeRadioGroup   File: RelativeRadioGroup.java   View source code 8 votes vote down vote up
/**
 * {@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);
    }
}
 
Example 3
Project: MetadataEditor   File: TintHelper.java   View source code 7 votes vote down vote up
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);
    }
}
 
Example 4
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AbstractIssueReporterActivity.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: CodeInPython   File: quiz2Fragment.java   View source code 6 votes vote down vote up
@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);
        }
    });
}
 
Example 6
Project: lineagex86   File: ZenModeConditionSelection.java   View source code 6 votes vote down vote up
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()));
    }
}
 
Example 7
Project: lineagex86   File: RedactionInterstitial.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 8
Project: GitHub   File: MDTintHelper.java   View source code 6 votes vote down vote up
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);
}
 
Example 9
Project: AdvancedTextView   File: HoriActivity.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: Runnest   File: RequestScheduleDialogFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: Android-Code-Demos   File: MainActivity.java   View source code 6 votes vote down vote up
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);
        }
    });*/
}
 
Example 12
Project: CodeInPython   File: quiz6Fragment.java   View source code 6 votes vote down vote up
@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);
        }
    });
}
 
Example 13
Project: android-CategoryPager   File: CategoryPagerNav.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 14
Project: LaunchTime   File: BackupActivity.java   View source code 6 votes vote down vote up
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;
}
 
Example 15
Project: android-CategoryPager   File: SegmentedControlAdapter.java   View source code 6 votes vote down vote up
@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;

}
 
Example 16
Project: Android-SteamVR-controller   File: WifiModeFragment.java   View source code 6 votes vote down vote up
@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();
}
 
Example 17
Project: MovingGdufe-Android   File: MainActivity.java   View source code 6 votes vote down vote up
@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;
            }
    }
}
 
Example 18
Project: gst-android-camera   File: CameraActivity.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 19
Project: CodeInPython   File: quiz7Fragment.java   View source code 6 votes vote down vote up
@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);
        }
    });
}
 
Example 20
Project: Navigation-bar   File: FlowRadioGroup.java   View source code 6 votes vote down vote up
/** 查找复合控件并设置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);
        }
    }
}
 
Example 21
Project: Navigation-bar   File: FlowRadioGroup.java   View source code 6 votes vote down vote up
/** 查找复合控件并设置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);
        }
    }
}
 
Example 22
Project: reflow-animator   File: AdvancedOptionsDialogFragment.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 23
Project: tuxguitar   File: TGMeasureAddDialog.java   View source code 6 votes vote down vote up
public int findSelectedMeasureNumber(View view) {
	RadioGroup optionsGroup = (RadioGroup) view.findViewById(R.id.measure_add_dlg_options_group);
	
	int radioButtonId = optionsGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) optionsGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return 1;
}
 
Example 24
Project: boohee_v5.6   File: ChangeEnvironmentActivity$$ViewInjector.java   View source code 6 votes vote down vote up
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'");
}
 
Example 25
Project: Beach-Android   File: PollResponseActivity.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 26
Project: RelativeRadioGroup   File: RelativeRadioGroup.java   View source code 6 votes vote down vote up
@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);
}
 
Example 27
Project: aos-Video   File: ModeSwitchDialog.java   View source code 6 votes vote down vote up
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;
}
 
Example 28
Project: Tusky   File: ComposeOptionsFragment.java   View source code 6 votes vote down vote up
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);
}
 
Example 29
Project: lineagex86   File: ZenModeConditionSelection.java   View source code 5 votes vote down vote up
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;
}
 
Example 30
Project: CXJPadProject   File: TestItemView.java   View source code 5 votes vote down vote up
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);
        }
    }
 
Example 31
Project: OSchina_resources_android   File: DialogAdapter.java   View source code 5 votes vote down vote up
@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;
}
 
Example 32
Project: GitHub   File: MDTintHelper.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 33
Project: GitHub   File: MultitaskTestActivity.java   View source code 5 votes vote down vote up
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);
}
 
Example 34
Project: Android-Client   File: CreateFilterActivity2.java   View source code 5 votes vote down vote up
@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());
}
 
Example 35
Project: TabPager   File: NavView.java   View source code 5 votes vote down vote up
/**
 * 设置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);
    }
}
 
Example 36
Project: IT405   File: MainActivity.java   View source code 5 votes vote down vote up
/**
 *  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);
}
 
Example 37
Project: OpenHomeAnalysis   File: OhaEnergyUseWhHolder.java   View source code 5 votes vote down vote up
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);
}
 
Example 38
Project: MeiLa_GNN   File: FragmentTabUtils.java   View source code 5 votes vote down vote up
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);
}
 
Example 39
Project: RNLearn_Project1   File: AccessibilityHelper.java   View source code 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
  super.onInitializeAccessibilityNodeInfo(host, info);
  info.setClassName(RadioButton.class.getName());
  info.setCheckable(true);
  info.setChecked(false);
}
 
Example 40
Project: AddressChecker   File: AddressListAdapter.java   View source code 5 votes vote down vote up
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);
}