下面列出了android.widget.RadioButton#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
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());
}
/**
* ピンを選択するための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;
}
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);
}
});
}
@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);
}
}
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);
}
}
@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);
}
}
}
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);
}
}
}
public void updateDurationsState(int id, boolean enabled) {
RadioButton radioButton = (RadioButton) this.getView().findViewById(id);
radioButton.setEnabled(enabled);
}
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());
}
}
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);
}
}
}
/**
* 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);
}
}