Java Code Examples for android.widget.RadioButton#setEnabled()

The following examples show how to use android.widget.RadioButton#setEnabled() . 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: SecurityPickerSlide.java    From Aegis with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_security_picker_slide, container, false);
    _buttonGroup = view.findViewById(R.id.rg_authenticationMethod);
    _buttonGroup.setOnCheckedChangeListener(this);
    onCheckedChanged(_buttonGroup, _buttonGroup.getCheckedRadioButtonId());

    // only enable the fingerprint option if the api version is new enough, permission is granted and a scanner is found
    if (BiometricsHelper.isAvailable(getContext())) {
        RadioButton button = view.findViewById(R.id.rb_biometrics);
        TextView text = view.findViewById(R.id.text_rb_biometrics);
        button.setEnabled(true);
        text.setEnabled(true);
        _buttonGroup.check(R.id.rb_biometrics);
    }

    view.findViewById(R.id.main).setBackgroundColor(_bgColor);
    return view;
}
 
Example 2
Source File: MainActivity.java    From QNRTC-Android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    setContentView(R.layout.activity_main);
    mRoomEditText = (EditText) findViewById(R.id.room_edit_text);
    mCaptureModeRadioGroup = findViewById(R.id.capture_mode_button);
    mCaptureModeRadioGroup.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mScreenCapture = (RadioButton) findViewById(R.id.screen_capture_button);
    mCameraCapture = (RadioButton) findViewById(R.id.camera_capture_button);
    mOnlyAudioCapture = (RadioButton) findViewById(R.id.audio_capture_button);
    mMutiTrackCapture = findViewById(R.id.muti_track_button);

    SharedPreferences preferences = getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE);
    String roomName = preferences.getString(Config.ROOM_NAME, Config.PILI_ROOM);
    int captureMode = preferences.getInt(Config.CAPTURE_MODE, Config.CAMERA_CAPTURE);
    if (QNScreenCaptureUtil.isScreenCaptureSupported()) {
        if (captureMode == Config.SCREEN_CAPTURE) {
            mScreenCapture.setChecked(true);
        } else if (captureMode == Config.CAMERA_CAPTURE) {
            mCameraCapture.setChecked(true);
        } else if (captureMode == Config.ONLY_AUDIO_CAPTURE){
            mOnlyAudioCapture.setChecked(true);
        } else {
            mMutiTrackCapture.setChecked(true);
        }
    } else {
        mScreenCapture.setEnabled(false);
    }
    mRoomEditText.setText(roomName);
    mRoomEditText.setSelection(roomName.length());
}
 
Example 3
Source File: FaBoPinRadioGroupFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * ピンを選択するためのRadioButtonを作成します.
 * @param inflater インフレータ
 * @param pin ピン
 * @return RadioButtonのインスタンス
 */
private RadioButton createRadioButton(final LayoutInflater inflater,final FaBoShield.Pin pin) {
    RadioButton radio = (RadioButton) inflater.inflate(R.layout.item_fabo_radio_button_pin, null, false);
    radio.setText(pin.getPinNames()[1]);
    radio.setTag(pin);
    radio.setEnabled(!usedPin(pin.getPinNumber()));
    radio.setOnCheckedChangeListener((compoundButton, b) -> {
        if (b) {
            mSelectedPin = pin;
        }
    });
    return radio;
}
 
Example 4
Source File: TGHarmonicDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void fillHarmonic(final int id, final int value, int selection, boolean enabled) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setTag(Integer.valueOf(value));
	radioButton.setChecked(value == selection);
	radioButton.setEnabled(enabled);
	radioButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			fillData(value, 0);
		}
	});
}
 
Example 5
Source File: SetupWizardSwitchTypeFragment.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
  super.onStart();

  // If the bluetooth adapter is null, it means that the device does not support Bluetooth, and we
  // should disable the option to pair a bluetooth switch.
  if (bluetoothAdapter == null) {
    RadioButton bluetoothSwitch = getRootView().findViewById(R.id.bluetooth_switch_radio_button);
    bluetoothSwitch.setChecked(false);
    bluetoothSwitch.setEnabled(false);
    TextView bluetoothDescriptionText =
        getRootView().findViewById(R.id.bluetooth_switch_option_description);
    bluetoothDescriptionText.setText(R.string.bluetooth_unsupported_description_text);
  }
}
 
Example 6
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void populateAnimationsRadioGroup(RadioGroup group, Set<RadioButtons.AnimationInfo> animationInfos) {
	for (RadioButtons.AnimationInfo animationInfo : animationInfos) {
		final RadioButton button = new RadioButton(this);
		final String text = getResources().getString(animationInfo.animationTextResId);
		button.setId(IdGenerator.next());
		button.setText(text);
		button.setTag(animationInfo);
		button.setEnabled(buttonBehaviorRadioGroup.getCheckedRadioButtonId() ==
				R.id.fab_activity_radiobutton_hide_and_show_on_click_radiobutton);
		group.addView(button);
	}
}
 
Example 7
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
	if (buttonBehaviorRadioGroup.equals(group)) {
		for (int i = 0; i < animationsRadioGroup.getChildCount(); i++) {
			RadioButton button = (RadioButton) animationsRadioGroup.getChildAt(i);
			button.setEnabled(checkedId == R.id.fab_activity_radiobutton_hide_and_show_on_click_radiobutton);
		}
		}
}
 
Example 8
Source File: MarketDetailActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void setKlineRadioButtonEnabled(boolean enabled) {
    int count = rg.getChildCount();
    for (int i = 0;
         i < count;
         i++) {
        View v = rg.getChildAt(i);
        if (v instanceof RadioButton) {
            RadioButton rb = (RadioButton) v;
            rb.setEnabled(enabled);
        }
    }
}
 
Example 9
Source File: TGStrokeDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void updateDurationsState(int id, boolean enabled) {
	RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
	radioButton.setEnabled(enabled);
}
 
Example 10
Source File: SelectOneWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    int padding = (int)Math.floor(context.getResources().getDimension(R.dimen.select_padding));

    mItems = getSelectChoices();
    buttons = new Vector<>();

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = prompt.getAnswerValue().uncast().getString();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {
            final RadioButton rb = new RadioButton(getContext());
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                rb.setText(forceMarkdown(markdownText));
            } else {
                rb.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
            rb.setId(i + buttonIdBase);
            rb.setEnabled(!prompt.isReadOnly());
            rb.setFocusable(!prompt.isReadOnly());

            rb.setBackgroundResource(R.drawable.selector_button_press);

            buttons.add(rb);

            if (mItems.get(i).getValue().equals(s)) {
                rb.setChecked(true);
            }

            //Move to be below the above setters. Not sure if that will cause
            //problems, but I don't think it should.
            rb.setOnCheckedChangeListener(this);

            String audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), rb, audioURI, imageURI, videoURI, bigImageURI);
            mediaLayout.setPadding(0, padding, 0, padding);
            mediaLayout.setEnabled(!mPrompt.isReadOnly());
            mediaLayout.setOnClickListener(v -> rb.performClick());
            addView(mediaLayout);


            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                addView(divider);
            }
        }
        addClearButton(context, s != null && !prompt.isReadOnly());
    }
}
 
Example 11
Source File: SelectOneAutoAdvanceWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    LayoutInflater inflater = LayoutInflater.from(getContext());

    mItems = getSelectChoices();
    buttons = new Vector<>();
    listener = (AdvanceToNextListener)context;

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {

            RelativeLayout thisParentLayout =
                    (RelativeLayout)inflater.inflate(R.layout.quick_select_layout, null);

            final LinearLayout questionLayout = (LinearLayout)thisParentLayout.getChildAt(0);
            ImageView rightArrow = (ImageView)thisParentLayout.getChildAt(1);

            final RadioButton r = new RadioButton(getContext());
            r.setOnCheckedChangeListener(this);
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                r.setText(forceMarkdown(markdownText));
            } else {
                r.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);
            r.setId(i + buttonIdBase);
            r.setEnabled(!prompt.isReadOnly());
            r.setFocusable(!prompt.isReadOnly());

            Drawable image = getResources().getDrawable(R.drawable.icon_auto_advance_arrow);
            rightArrow.setImageDrawable(image);
            rightArrow.setOnTouchListener((v, event) -> {
                r.onTouchEvent(event);
                return false;
            });

            buttons.add(r);

            if (mItems.get(i).getValue().equals(s)) {
                r.setChecked(true);
            }

            String audioURI = null;
            audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI = null;
            imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), r, audioURI, imageURI, videoURI, bigImageURI);

            questionLayout.addView(mediaLayout);

            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                mediaLayout.addDivider(divider);
            }

            addView(thisParentLayout);
        }
    }
}
 
Example 12
Source File: WriteTag.java    From MifareClassicTool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initialize the layout and some member variables. If the Intent
 * contains {@link #EXTRA_DUMP} (and therefore was send from
 * {@link DumpEditor}), the write dump option will be adjusted
 * accordingly.
 */
// It is checked but the IDE don't get it.
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_write_tag);

    mSectorTextBlock = findViewById(R.id.editTextWriteTagSector);
    mBlockTextBlock = findViewById(R.id.editTextWriteTagBlock);
    mDataText = findViewById(R.id.editTextWriteTagData);
    mSectorTextVB = findViewById(
            R.id.editTextWriteTagValueBlockSector);
    mBlockTextVB = findViewById(
            R.id.editTextWriteTagValueBlockBlock);
    mNewValueTextVB = findViewById(
            R.id.editTextWriteTagValueBlockValue);
    mIncreaseVB = findViewById(
            R.id.radioButtonWriteTagWriteValueBlockIncr);
    mStaticAC = findViewById(R.id.editTextWriteTagDumpStaticAC);
    mEnableStaticAC = findViewById(
            R.id.checkBoxWriteTagDumpStaticAC);
    mWriteManufBlock = findViewById(
            R.id.checkBoxWriteTagDumpWriteManuf);

    mWriteModeLayouts = new ArrayList<>();
    mWriteModeLayouts.add(findViewById(
            R.id.relativeLayoutWriteTagWriteBlock));
    mWriteModeLayouts.add(findViewById(R.id.linearLayoutWriteTagDump));
    mWriteModeLayouts.add(findViewById(
            R.id.linearLayoutWriteTagFactoryFormat));
    mWriteModeLayouts.add(findViewById(
            R.id.relativeLayoutWriteTagValueBlock));

    // Restore mDumpWithPos and the "write to manufacturer block"-state.
    if (savedInstanceState != null) {
        mWriteManufBlock.setChecked(
                savedInstanceState.getBoolean("write_manuf_block", false));
        Serializable s = savedInstanceState
                .getSerializable("dump_with_pos");
        if (s instanceof HashMap<?, ?>) {
            mDumpWithPos = (HashMap<Integer, HashMap<Integer, byte[]>>) s;
        }
    }

    Intent i = getIntent();
    if (i.hasExtra(EXTRA_DUMP)) {
        // Write dump directly from editor.
        mDumpFromEditor = i.getStringArrayExtra(EXTRA_DUMP);
        mWriteDumpFromEditor = true;
        // Show "Write Dump" option and disable other write options.
        RadioButton writeBlock = findViewById(
                R.id.radioButtonWriteTagWriteBlock);
        RadioButton factoryFormat = findViewById(
                R.id.radioButtonWriteTagFactoryFormat);
        RadioButton writeDump = findViewById(
                R.id.radioButtonWriteTagWriteDump);
        writeDump.performClick();
        writeBlock.setEnabled(false);
        factoryFormat.setEnabled(false);
        // Update button text.
        Button writeDumpButton = findViewById(
                R.id.buttonWriteTagDump);
        writeDumpButton.setText(R.string.action_write_dump);
    }
}