Here are the examples of the java api android.widget.RadioButton taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
516 Examples
19
Source : CreateOrderActivity.java
with Apache License 2.0
from zxuu
with Apache License 2.0
from zxuu
public void selectPayChannle(String paychannel) {
for (Map.Entry<String, RadioButton> entry : channels.entrySet()) {
payChannel = paychannel;
RadioButton rb = entry.getValue();
if (entry.getKey().equals(paychannel)) {
boolean isCheck = rb.isChecked();
rb.setChecked(!isCheck);
} else
rb.setChecked(false);
}
}
19
Source : ScheduleCallActivity.java
with BSD 2-Clause "Simplified" License
from zolamk
with BSD 2-Clause "Simplified" License
from zolamk
public void onClickSchedule(View view) {
EditText nameInput = (EditText) findViewById(R.id.nameInput);
EditText numberInput = (EditText) findViewById(R.id.numberInput);
EditText timeInput = (EditText) findViewById(R.id.scheduleTimePicker);
EditText durationInput = (EditText) findViewById(R.id.callDurationInput);
EditText hangUpAfterInput = (EditText) findViewById(R.id.hangUpAfterInput);
String name = nameInput.getText().toString();
String number = numberInput.getText().toString();
String time = timeInput.getText().toString();
String duration = durationInput.getText().toString();
String hangUpAfter = hangUpAfterInput.getText().toString();
if (number.equals("")) {
Toast.makeText(this, "Number can't be empty!", Toast.LENGTH_SHORT).show();
return;
}
if (time.equals("")) {
Toast.makeText(this, "Call time can't be empty", Toast.LENGTH_SHORT).show();
return;
}
if (name.equals("")) {
name = getResources().getString(R.string.unknown);
}
if (duration.equals("")) {
duration = Integer.toString(DURATION);
}
if (hangUpAfter.equals("")) {
hangUpAfter = Integer.toString(HANA_UP_AFTER);
}
RadioButton radioButton = (RadioButton) findViewById(callType.getCheckedRadioButtonId());
int radioButtonIndex = callType.indexOfChild(radioButton);
ContentResolver contentResolver = getContentResolver();
if (radioButtonIndex == 0) {
Intent intent = new Intent(this, FakeRingerActivity.clreplaced);
intent.putExtra("name", name);
intent.putExtra("number", "Mobile " + number);
intent.putExtra("contactImage", contactImage);
intent.putExtra("duration", Integer.parseInt(duration));
intent.putExtra("hangUpAfter", Integer.parseInt(hangUpAfter));
intent.putExtra("voice", voice);
final int fakeCallID = (int) System.currentTimeMillis();
PendingIntent pendingIntent = PendingIntent.getActivity(this, fakeCallID, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
Toast.makeText(this, "Fake call scheduled", Toast.LENGTH_SHORT).show();
finish();
} else if (radioButtonIndex == 1) {
CallLogUtilities.addCallToLog(contentResolver, number, Integer.parseInt(duration), CallLog.Calls.OUTGOING_TYPE, calendar.getTimeInMillis());
Toast.makeText(this, "Fake outgoing call added to log", Toast.LENGTH_SHORT).show();
} else if (radioButtonIndex == 2) {
CallLogUtilities.addCallToLog(contentResolver, number, 0, CallLog.Calls.MISSED_TYPE, calendar.getTimeInMillis());
Toast.makeText(this, "Fake missed call added to log", Toast.LENGTH_SHORT).show();
}
}
19
Source : MainActivity.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
/**
* Link to: https://github.com/youlookwhat/WebViewStudy
* contact me: https://www.jianshu.com/u/e43c6e979831
*/
public clreplaced MainActivity extends AppCompatActivity implements View.OnClickListener {
// 是否开启了主页,没有开启则会返回主页
public static boolean isLaunch = false;
private AutoCompleteTextView etSearch;
private RadioButton rbSystem;
private int state = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.colorPrimary), 0);
initView();
isLaunch = true;
}
private void initView() {
findViewById(R.id.bt_deeplink).setOnClickListener(this);
findViewById(R.id.bt_openUrl).setOnClickListener(this);
findViewById(R.id.bt_baidu).setOnClickListener(this);
findViewById(R.id.bt_movie).setOnClickListener(this);
findViewById(R.id.bt_upload_photo).setOnClickListener(this);
findViewById(R.id.bt_call).setOnClickListener(this);
findViewById(R.id.bt_java_js).setOnClickListener(this);
findViewById(R.id.bt_toolbar).setOnClickListener(this);
rbSystem = findViewById(R.id.rb_system);
etSearch = findViewById(R.id.et_search);
rbSystem.setChecked(true);
TextView tvVersion = findViewById(R.id.tv_version);
tvVersion.setText(String.format("❤版本:v%s", BuildConfig.VERSION_NAME));
tvVersion.setOnClickListener(this);
/**
* 处理键盘搜索键
*/
etSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
openUrl();
}
return false;
}
});
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.bt_openUrl:
openUrl();
break;
case // 百度一下
R.id.bt_baidu:
state = 0;
String baiDuUrl = "http://www.baidu.com";
loadUrl(baiDuUrl, getString(R.string.text_baidu));
break;
case // 网络视频
R.id.bt_movie:
state = 0;
String movieUrl = "https://sv.baidu.com/videoui/page/videoland?context=%7B%22nid%22%3A%22sv_5861863042579737844%22%7D&pd=feedtab_h5";
loadUrl(movieUrl, getString(R.string.text_movie));
break;
case // 上传图片
R.id.bt_upload_photo:
state = 0;
String uploadUrl = "file:///android_replacedet/upload_photo.html";
loadUrl(uploadUrl, getString(R.string.text_upload_photo));
break;
case // 打电话、发短信、发邮件、JS
R.id.bt_call:
state = 1;
String callUrl = "file:///android_replacedet/callsms.html";
loadUrl(callUrl, getString(R.string.text_js));
break;
case // js与android原生代码互调
R.id.bt_java_js:
state = 2;
String javaJs = "file:///android_replacedet/java_js.html";
loadUrl(javaJs, getString(R.string.js_android));
break;
case // DeepLink通过网页跳入App
R.id.bt_deeplink:
state = 0;
String deepLinkUrl = "file:///android_replacedet/deeplink.html";
loadUrl(deepLinkUrl, getString(R.string.deeplink));
break;
case // 与ToolBar联动,自定义WebView
R.id.bt_toolbar:
CoordinatorWebActivity.loadUrl(this, "http://www.baidu.com", "百度一下", 0);
break;
case R.id.tv_version:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setreplacedle("感谢");
builder.setMessage("开源不易,给作者一个star好吗?😊");
builder.setNegativeButton("已给", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "感谢老铁~", Toast.LENGTH_LONG).show();
}
});
builder.setPositiveButton("去star", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
state = 0;
loadUrl("https://github.com/youlookwhat/WebViewStudy", "WebViewStudy");
}
});
builder.show();
break;
default:
break;
}
}
/**
* 打开网页
*/
private void openUrl() {
state = 0;
String url = ByWebTools.getUrl(etSearch.getText().toString().trim());
loadUrl(!TextUtils.isEmpty(url) ? url : "https://github.com/youlookwhat/WebViewStudy", "详情");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.gereplacedemId()) {
case R.id.actionbar_update:
state = 0;
loadUrl("http://d.6short.com/webviewstudy", "网页浏览器 - fir.im");
break;
case R.id.actionbar_about:
state = 0;
loadUrl("https://github.com/youlookwhat/WebViewStudy", "WebViewStudy");
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
private void loadUrl(String mUrl, String mreplacedle) {
if (rbSystem.isChecked()) {
// WebViewActivity.loadUrl(this, mUrl, mreplacedle);
ByWebViewActivity.loadUrl(this, mUrl, mreplacedle, state);
} else {
X5WebViewActivity.loadUrl(this, mUrl, mreplacedle);
}
}
public static void start(Context context) {
context.startActivity(new Intent(context, MainActivity.clreplaced));
}
@Override
protected void onDestroy() {
super.onDestroy();
isLaunch = false;
}
}
19
Source : NavView.java
with Apache License 2.0
from yhyzgn
with Apache License 2.0
from yhyzgn
/**
* 设置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);
}
}
19
Source : TabControlView.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
/**
* 通过标题设置选中的Tab
*
* @param replacedle
* @param isSilent 是否静默设置
* @return
*/
public TabControlView setSelectionreplacedle(String replacedle, boolean isSilent) {
for (RadioButton option : mOptions) {
if (option.getText().toString().equalsIgnoreCase(replacedle)) {
if (isSilent) {
setOnCheckedChangeListener(null);
this.check(option.getId());
setOnCheckedChangeListener(mSelectionChangedListener);
} else {
this.check(option.getId());
}
}
}
return this;
}
19
Source : TabControlView.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
/**
* 更新RadioButton的显示
*
* @param rb
* @param tcv_option_normal
* @param tcv_option_selected
*/
private void updateRadioButton(RadioButton rb, int tcv_option_normal, int tcv_option_selected) {
GradientDrawable unselected = (GradientDrawable) mContext.getResources().getDrawable(tcv_option_normal).mutate();
unselected.setStroke(mStrokeWidth, mSelectedColor);
unselected.setDither(true);
unselected.setColor(mUnselectedColor);
GradientDrawable selected = (GradientDrawable) mContext.getResources().getDrawable(tcv_option_selected).mutate();
selected.setColor(mSelectedColor);
selected.setStroke(mStrokeWidth, mSelectedColor);
setRadioButtonBackground(rb, unselected, selected);
}
19
Source : TabControlView.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
/**
* 设置RadioButton的背景
*
* @param rb
* @param unselected
* @param selected
*/
private void setRadioButtonBackground(RadioButton rb, GradientDrawable unselected, GradientDrawable selected) {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] { -android.R.attr.state_checked }, unselected);
stateListDrawable.addState(new int[] { android.R.attr.state_checked }, selected);
if (Build.VERSION.SDK_INT < JELLY_BEAN) {
rb.setBackgroundDrawable(stateListDrawable);
} else {
rb.setBackground(stateListDrawable);
}
}
19
Source : MDTintHelper.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color) {
final int disabledColor = ThemeUtils.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[] { ThemeUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal), color, disabledColor, disabledColor });
setTint(radioButton, sl);
}
19
Source : DefaultRvAdapter.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
@Override
public void onBindViewHolder(DefaultVH holder, int index) {
final View view = holder.itemView;
boolean disabled = ThemeUtils.isIn(index, dialog.builder.disabledIndices);
int itemTextColor = disabled ? ThemeUtils.adjustAlpha(dialog.builder.itemColor, 0.4f) : dialog.builder.itemColor;
holder.itemView.setEnabled(!disabled);
switch(dialog.listType) {
case SINGLE:
{
@SuppressLint("CutPasteId")
RadioButton radio = (RadioButton) holder.control;
boolean selected = dialog.builder.selectedIndex == index;
if (dialog.builder.choiceWidgetColor != null) {
MDTintHelper.setTint(radio, dialog.builder.choiceWidgetColor);
} else {
MDTintHelper.setTint(radio, dialog.builder.widgetColor);
}
radio.setChecked(selected);
radio.setEnabled(!disabled);
break;
}
case MULTI:
{
@SuppressLint("CutPasteId")
CheckBox checkbox = (CheckBox) holder.control;
boolean selected = dialog.selectedIndicesList.contains(index);
if (dialog.builder.choiceWidgetColor != null) {
MDTintHelper.setTint(checkbox, dialog.builder.choiceWidgetColor);
} else {
MDTintHelper.setTint(checkbox, dialog.builder.widgetColor);
}
checkbox.setChecked(selected);
checkbox.setEnabled(!disabled);
break;
}
default:
break;
}
holder.replacedle.setText(dialog.builder.items.get(index));
holder.replacedle.setTextColor(itemTextColor);
dialog.setTypeface(holder.replacedle, dialog.builder.regularFont);
setupGravity((ViewGroup) view);
if (dialog.builder.itemIds != null) {
if (index < dialog.builder.itemIds.length) {
view.setId(dialog.builder.itemIds[index]);
} else {
view.setId(-1);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ViewGroup group = (ViewGroup) view;
if (group.getChildCount() == 2) {
// Remove circular selector from check boxes and radio buttons on Lollipop
if (group.getChildAt(0) instanceof CompoundButton) {
group.getChildAt(0).setBackground(null);
} else if (group.getChildAt(1) instanceof CompoundButton) {
group.getChildAt(1).setBackground(null);
}
}
}
}
19
Source : BadgeViewFragment.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
@Override
protected void initViews() {
initBadge();
radioButtons.add(findViewById(R.id.rb_st));
radioButtons.add(findViewById(R.id.rb_sb));
RadioButton rbEt = findViewById(R.id.rb_et);
lastRadioButton = rbEt;
radioButtons.add(rbEt);
radioButtons.add(findViewById(R.id.rb_eb));
radioButtons.add(findViewById(R.id.rb_ct));
radioButtons.add(findViewById(R.id.rb_ce));
radioButtons.add(findViewById(R.id.rb_cb));
radioButtons.add(findViewById(R.id.rb_cs));
radioButtons.add(findViewById(R.id.rb_c));
}
19
Source : MainActivity.java
with Apache License 2.0
from wotomas
with Apache License 2.0
from wotomas
private void initializeControlPanel() {
playButton = (Button) findViewById(R.id.voice_play_button);
playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (directory != null && audioFile != null) {
player = new MediaPlayer();
try {
player.setDataSource(audioFile.getAbsolutePath());
player.prepare();
player.start();
} catch (IOException e) {
Log.e(TAG, "prepare() failed");
}
}
}
});
ColorPicker picker = (ColorPicker) findViewById(R.id.picker);
picker.setShowOldCenterColor(false);
picker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
@Override
public void onColorChanged(int color) {
voiceRipple.setRippleColor(color);
}
});
SeekBar iconSizeSeekBar = (SeekBar) findViewById(R.id.icon_size_seekbar);
iconSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
voiceRipple.setIconSize(i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
SeekBar rippleSizeSeekbar = (SeekBar) findViewById(R.id.ripple_size_seekbar);
rippleSizeSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (i == 0 || i == 100)
return;
double ratio = 0.5 + ((double) i / 100.0);
voiceRipple.setBackgroundRippleRatio(ratio);
Log.d(TAG, "onBackgroundRippleRatio ChangedL " + ratio);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
final RadioButton low = (RadioButton) findViewById(R.id.option1);
final RadioButton medium = (RadioButton) findViewById(R.id.option2);
final RadioButton high = (RadioButton) findViewById(R.id.option3);
RadioButton.OnClickListener optionOnClickListener = new RadioButton.OnClickListener() {
@Override
public void onClick(View view) {
if (low.isChecked()) {
voiceRipple.setRippleDecayRate(Rate.LOW);
} else if (medium.isChecked()) {
voiceRipple.setRippleDecayRate(Rate.MEDIUM);
} else if (high.isChecked()) {
voiceRipple.setRippleDecayRate(Rate.HIGH);
}
}
};
low.setOnClickListener(optionOnClickListener);
medium.setOnClickListener(optionOnClickListener);
high.setOnClickListener(optionOnClickListener);
high.setChecked(true);
final RadioButton low1 = (RadioButton) findViewById(R.id.option4);
final RadioButton medium1 = (RadioButton) findViewById(R.id.option5);
final RadioButton high1 = (RadioButton) findViewById(R.id.option6);
RadioButton.OnClickListener optionOnClickListener2 = new RadioButton.OnClickListener() {
@Override
public void onClick(View view) {
if (low1.isChecked()) {
voiceRipple.setRippleSampleRate(Rate.LOW);
} else if (medium1.isChecked()) {
voiceRipple.setRippleSampleRate(Rate.MEDIUM);
} else if (high1.isChecked()) {
voiceRipple.setRippleSampleRate(Rate.HIGH);
}
}
};
low1.setOnClickListener(optionOnClickListener);
medium1.setOnClickListener(optionOnClickListener);
high1.setOnClickListener(optionOnClickListener);
low1.setChecked(true);
}
19
Source : TimeRangePickerDialog.java
with Apache License 2.0
from WithLei
with Apache License 2.0
from WithLei
private void setRadioBtnSize(RadioButton btn) {
btn.setTextSize(10);
btn.setGravity(Gravity.CENTER);
}
19
Source : MainActivity.java
with GNU General Public License v3.0
from WeGdufe
with GNU General Public License v3.0
from WeGdufe
@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_social:
if (checked) {
fUtil.show(mFragments.get(2));
break;
}
case R.id.rd_me:
if (checked) {
if (isAlpha) {
fUtil.show(mFragments.get(3));
break;
} else {
fUtil.show(mFragments.get(2));
break;
}
}
}
}
19
Source : SensorsDataPrivate.java
with Apache License 2.0
from wangzhzh
with Apache License 2.0
from wangzhzh
/**
* 获取 View 上显示的文本
*
* @param view View
* @return String
*/
public static String getElementContent(View view) {
if (view == null) {
return null;
}
CharSequence viewText = null;
if (view instanceof CheckBox) {
// CheckBox
CheckBox checkBox = (CheckBox) view;
viewText = checkBox.getText();
} else if (view instanceof SwitchCompat) {
SwitchCompat switchCompat = (SwitchCompat) view;
viewText = switchCompat.getTextOn();
} else if (view instanceof RadioButton) {
// RadioButton
RadioButton radioButton = (RadioButton) view;
viewText = radioButton.getText();
} else if (view instanceof ToggleButton) {
// ToggleButton
ToggleButton toggleButton = (ToggleButton) view;
boolean isChecked = toggleButton.isChecked();
if (isChecked) {
viewText = toggleButton.getTextOn();
} else {
viewText = toggleButton.getTextOff();
}
} else if (view instanceof Button) {
// Button
Button button = (Button) view;
viewText = button.getText();
} else if (view instanceof CheckedTextView) {
// CheckedTextView
CheckedTextView textView = (CheckedTextView) view;
viewText = textView.getText();
} else if (view instanceof TextView) {
// TextView
TextView textView = (TextView) view;
viewText = textView.getText();
} else if (view instanceof SeekBar) {
SeekBar seekBar = (SeekBar) view;
viewText = String.valueOf(seekBar.getProgress());
} else if (view instanceof RatingBar) {
RatingBar ratingBar = (RatingBar) view;
viewText = String.valueOf(ratingBar.getRating());
}
if (viewText != null) {
return viewText.toString();
}
return null;
}
19
Source : SensorsDataPrivate.java
with Apache License 2.0
from wangzhzh
with Apache License 2.0
from wangzhzh
public static String traverseViewContent(StringBuilder stringBuilder, ViewGroup root) {
try {
if (root == null) {
return stringBuilder.toString();
}
final int childCount = root.getChildCount();
for (int i = 0; i < childCount; ++i) {
final View child = root.getChildAt(i);
if (child.getVisibility() != View.VISIBLE) {
continue;
}
if (child instanceof ViewGroup) {
traverseViewContent(stringBuilder, (ViewGroup) child);
} else {
CharSequence viewText = null;
if (child instanceof CheckBox) {
CheckBox checkBox = (CheckBox) child;
viewText = checkBox.getText();
} else if (child instanceof SwitchCompat) {
SwitchCompat switchCompat = (SwitchCompat) child;
viewText = switchCompat.getTextOn();
} else if (child instanceof RadioButton) {
RadioButton radioButton = (RadioButton) child;
viewText = radioButton.getText();
} else if (child instanceof ToggleButton) {
ToggleButton toggleButton = (ToggleButton) child;
boolean isChecked = toggleButton.isChecked();
if (isChecked) {
viewText = toggleButton.getTextOn();
} else {
viewText = toggleButton.getTextOff();
}
} else if (child instanceof Button) {
Button button = (Button) child;
viewText = button.getText();
} else if (child instanceof CheckedTextView) {
CheckedTextView textView = (CheckedTextView) child;
viewText = textView.getText();
} else if (child instanceof TextView) {
TextView textView = (TextView) child;
viewText = textView.getText();
} else if (child instanceof ImageView) {
ImageView imageView = (ImageView) child;
if (!TextUtils.isEmpty(imageView.getContentDescription())) {
viewText = imageView.getContentDescription().toString();
}
}
if (!TextUtils.isEmpty(viewText)) {
stringBuilder.append(viewText.toString());
stringBuilder.append("-");
}
}
}
return stringBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
return stringBuilder.toString();
}
}
19
Source : GoodsFragment.java
with Apache License 2.0
from wangzhijun1124
with Apache License 2.0
from wangzhijun1124
private void initRadioGroup(List<GoodsDetail> goodsDetails) {
for (GoodsDetail g : goodsDetails) {
RadioButton radioButton = new RadioButton(getContext());
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
radioButton.setLayoutParams(layoutParams);
radioButton.setId(g.getGoodsdetail_id());
radioButton.setText(g.getAttr_name() + "\r\r\r\r\r库存" + g.getGoods_count());
radioButton.setTextSize(25);
radioButton.setTag(g);
// 设置选中/未选中的文字颜色
radioButton.setTextColor(getResources().getColorStateList(R.color.base_blue_selector));
// 设置按钮选中/未选中的背景
radioButton.setBackground(getResources().getDrawable(R.drawable.bg_btn_style_white));
group.addView(radioButton);
}
group.check(goodsDetails.get(0).getGoodsdetail_id());
}
19
Source : SettingsFragment.java
with Apache License 2.0
from w3-engineers
with Apache License 2.0
from w3-engineers
private void showLanguageChangeDialog() {
// {"English", "Bangla"};
String[] languageList = mActivity.getResources().getStringArray(R.array.language_list);
String[] languageCodeList = mActivity.getResources().getStringArray(R.array.language_code_list);
String currentLanguage = settingsViewModel.getAppLanguage();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = this.getLayoutInflater();
@SuppressLint("InflateParams")
View dialogView = inflater.inflate(R.layout.alert_language_dialog, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
RadioGroup languageGroup = dialogView.findViewById(R.id.radio_group_language);
for (int i = 0; i < languageGroup.getChildCount(); i++) {
RadioButton radioButton = (RadioButton) languageGroup.getChildAt(i);
radioButton.setText(languageList[i]);
if (currentLanguage.equals(languageList[i])) {
radioButton.setChecked(true);
}
}
languageGroup.setOnCheckedChangeListener((group, checkedId) -> {
switch(checkedId) {
case R.id.radio_english:
settingsViewModel.setLocale(languageCodeList[0], languageList[0]);
alertDialog.dismiss();
if (getActivity() != null) {
getActivity().finish();
Intent intent = getActivity().getIntent();
intent.putExtra(MainActivity.clreplaced.getSimpleName(), true);
startActivity(intent);
}
break;
case R.id.radio_bangla:
settingsViewModel.setLocale(languageCodeList[1], languageList[1]);
alertDialog.dismiss();
if (getActivity() != null) {
getActivity().finish();
Intent intent = getActivity().getIntent();
intent.putExtra(MainActivity.clreplaced.getSimpleName(), true);
startActivity(intent);
}
break;
}
});
alertDialog.show();
}
19
Source : RadioButtonPreference.java
with Apache License 2.0
from VladThodo
with Apache License 2.0
from VladThodo
/**
* Radio Button preference
*/
public clreplaced RadioButtonPreference extends Preference {
interface OnRadioButtonClickedListener {
/**
* Called when this preference needs to be saved its state.
*
* @param preference This preference.
*/
void onRadioButtonClicked(RadioButtonPreference preference);
}
private boolean mIsSelected;
private RadioButton mRadioButton;
private OnRadioButtonClickedListener mListener;
private final View.OnClickListener mClickListener = new View.OnClickListener() {
@Override
public void onClick(final View v) {
callListenerOnRadioButtonClicked();
}
};
public RadioButtonPreference(final Context context) {
this(context, null);
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
public void setOnRadioButtonClickedListener(final OnRadioButtonClickedListener listener) {
mListener = listener;
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
void callListenerOnRadioButtonClicked() {
if (mListener != null) {
mListener.onRadioButtonClicked(this);
}
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
// disable parent click
holder.itemView.setClickable(false);
mRadioButton = (RadioButton) holder.findViewById(R.id.radio_button);
mRadioButton.setChecked(mIsSelected);
mRadioButton.setOnClickListener(mClickListener);
}
public void setSelected(final boolean selected) {
if (selected == mIsSelected) {
return;
}
mIsSelected = selected;
if (mRadioButton != null) {
mRadioButton.setChecked(selected);
}
notifyChanged();
}
}
19
Source : MainActivity.java
with GNU General Public License v3.0
from VDavid003
with GNU General Public License v3.0
from VDavid003
private void setEnableFlags(RadioButton selected) {
int i = 0;
for (CheckBox checkBox : getFlagCheckboxes(flags)) {
checkBox.setEnabled(FlagsMap.get(selected.getText())[i]);
i++;
}
findViewById(R.id.r96Patch).setEnabled(selected.getText().equals("ex/nightly"));
findViewById(R.id._60fpsPatch).setEnabled(!selected.getText().equals("ex/master"));
}
19
Source : MainActivity.java
with GNU General Public License v3.0
from VDavid003
with GNU General Public License v3.0
from VDavid003
private String GetBranch() {
int buttonId = branch.getCheckedRadioButtonId();
RadioButton radioButton = branch.findViewById(buttonId);
if (radioButton == null)
return "master";
return radioButton.getText().toString();
}
19
Source : ThemeHelper.java
with GNU General Public License v3.0
from UnevenSoftware
with GNU General Public License v3.0
from UnevenSoftware
public void themeRadioButton(RadioButton radioButton) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setButtonTintList(getTintList());
radioButton.setTextColor(getTextColor());
}
}
19
Source : ThemedActivity.java
with GNU General Public License v3.0
from UnevenSoftware
with GNU General Public License v3.0
from UnevenSoftware
public void themeRadioButton(RadioButton radioButton) {
themeHelper.themeRadioButton(radioButton);
}
19
Source : DialogPreferenceMenuBarPosition.java
with GNU General Public License v3.0
from TobiasBielefeld
with GNU General Public License v3.0
from TobiasBielefeld
/**
* dialog for changing the rows shown in the menu. It uses different values for portrait and landscape
*/
public clreplaced DialogPreferenceMenuBarPosition extends CustomDialogPreference {
RadioButton top, bottom, left, right;
private static String BOTTOM = "bottom";
private static String RIGHT = "right";
public DialogPreferenceMenuBarPosition(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.dialog_settings_menu_bar_position);
setDialogIcon(null);
}
@Override
protected void onBindDialogView(View view) {
top = view.findViewById(R.id.dialog_button_portrait_top);
bottom = view.findViewById(R.id.dialog_button_portrait_bottom);
left = view.findViewById(R.id.dialog_button_landscape_left);
right = view.findViewById(R.id.dialog_button_landscape_right);
if (prefs.getSavedMenuBarPosPortrait().equals(BOTTOM)) {
bottom.setChecked(true);
} else {
top.setChecked(true);
}
if (prefs.getSavedMenuBarPosLandscape().equals(RIGHT)) {
right.setChecked(true);
} else {
left.setChecked(true);
}
super.onBindDialogView(view);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
String TOP = "top";
prefs.saveMenuBarPosPortrait(bottom.isChecked() ? BOTTOM : TOP);
String LEFT = "left";
prefs.saveMenuBarPosLandscape(right.isChecked() ? RIGHT : LEFT);
}
}
}
19
Source : DialogPreferenceGameLayoutMargins.java
with GNU General Public License v3.0
from TobiasBielefeld
with GNU General Public License v3.0
from TobiasBielefeld
/**
* dialog for changing the rows shown in the menu. It uses different values for portrait and landscape
*/
public clreplaced DialogPreferenceGameLayoutMargins extends CustomDialogPreference {
RadioButton[] portrait = new RadioButton[4];
RadioButton[] landscape = new RadioButton[4];
public DialogPreferenceGameLayoutMargins(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.dialog_settings_game_layout_margins);
setDialogIcon(null);
}
@Override
protected void onBindDialogView(View view) {
portrait[0] = view.findViewById(R.id.dialog_button_portrait_none);
portrait[1] = view.findViewById(R.id.dialog_button_portrait_small);
portrait[2] = view.findViewById(R.id.dialog_button_portrait_medium);
portrait[3] = view.findViewById(R.id.dialog_button_portrait_large);
landscape[0] = view.findViewById(R.id.dialog_button_landscape_none);
landscape[1] = view.findViewById(R.id.dialog_button_landscape_small);
landscape[2] = view.findViewById(R.id.dialog_button_landscape_medium);
landscape[3] = view.findViewById(R.id.dialog_button_landscape_large);
portrait[prefs.getSavedGameLayoutMarginsPortrait()].setChecked(true);
landscape[prefs.getSavedGameLayoutMarginsLandscape()].setChecked(true);
super.onBindDialogView(view);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
int portraitValue = 0, landscapeValue = 0;
for (int i = 0; i < 4; i++) {
if (portrait[i].isChecked()) {
portraitValue = i;
}
if (landscape[i].isChecked()) {
landscapeValue = i;
}
}
prefs.saveGameLayoutMarginsPortrait(portraitValue);
prefs.saveGameLayoutMarginsLandscape(landscapeValue);
}
}
}
19
Source : BannerView.java
with Apache License 2.0
from TLocation
with Apache License 2.0
from TLocation
@Override
public void onPageSelected(int position) {
int index = position % imgs.size();
if (!replacedles.isEmpty()) {
textView.setText(replacedles.get(index));
} else {
RadioButton childAt = (RadioButton) radioGroup.getChildAt(index);
childAt.setChecked(true);
}
}
19
Source : BannerView.java
with Apache License 2.0
from TLocation
with Apache License 2.0
from TLocation
//
// public void setreplacedles(Collection<String> replacedle) {
// replacedles.clear();
// replacedles.addAll(replacedle);
// }
public void setData(List datas) {
radioGroup.removeAllViews();
imgs.clear();
int length = datas.size();
if (!replacedles.isEmpty()) {
removeView(radioGroup);
textView = new TextView(context);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
textView.setLayoutParams(params);
textView.setGravity(Gravity.CENTER_VERTICAL);
textView.setPadding(5, 5, 5, 5);
textView.setTextColor(Color.WHITE);
textView.setBackgroundColor(Color.parseColor("#4d000000"));
addView(textView);
LogUtils.d("添加数据源");
for (int i = 0; i < length; i++) {
initImageView(i, datas.get(i));
}
} else {
for (int i = 0; i < length; i++) {
// 这里初始化适配器 初始化指示器 构造view
RadioButton radioButton = initData(length, i, datas.get(i));
radioGroup.addView(radioButton);
}
}
bannerAdapter = new BannerAdapter(imgs);
viewpager.setAdapter(bannerAdapter);
viewpager.setCurrenreplacedem(DEFAULT_NUMBER / 2);
if (isPlayStart) {
startPlay();
}
}
19
Source : BannerView.java
with Apache License 2.0
from TLocation
with Apache License 2.0
from TLocation
@NonNull
private RadioButton initData(int length, int i, Object imagepath) {
initImageView(i, imagepath);
RadioButton radioButton = new RadioButton(context);
if (selectTab != 0) {
radioButton.setBackgroundResource(selectTab);
radioButton.setButtonDrawable(context.getResources().getDrawable(android.R.color.transparent));
}
RadioGroup.LayoutParams buttonParams = new RadioGroup.LayoutParams(tabWidth, tabHeight);
if (i != length - 1) {
buttonParams.setMargins(0, 0, tabMargin, 0);
}
radioButton.setLayoutParams(buttonParams);
radioButton.setId(i);
if (i == 0)
radioButton.setChecked(true);
return radioButton;
}
19
Source : TintHelper.java
with GNU General Public License v3.0
from timusus
with GNU General Public License v3.0
from timusus
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
Util.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 {
@SuppressLint("PrivateResource")
Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
radioButton.setButtonDrawable(d);
}
}
19
Source : TDUtils.java
with Apache License 2.0
from ThinkingDataAnalytics
with Apache License 2.0
from ThinkingDataAnalytics
public static String traverseView(StringBuilder stringBuilder, ViewGroup root) {
try {
if (root == null) {
return stringBuilder.toString();
}
final int childCount = root.getChildCount();
for (int i = 0; i < childCount; ++i) {
final View child = root.getChildAt(i);
if (child.getVisibility() != View.VISIBLE) {
continue;
}
if (child instanceof ViewGroup) {
traverseView(stringBuilder, (ViewGroup) child);
} else {
// if (isViewIgnored(child)) {
// continue;
// }
Clreplaced<?> switchCompatClreplaced = null;
try {
switchCompatClreplaced = Clreplaced.forName("android.support.v7.widget.SwitchCompat");
} catch (Exception e) {
// ignored
}
if (switchCompatClreplaced == null) {
try {
switchCompatClreplaced = Clreplaced.forName("androidx.appcompat.widget.SwitchCompat");
} catch (Exception e) {
// ignored
}
}
CharSequence viewText = null;
if (child instanceof CheckBox) {
CheckBox checkBox = (CheckBox) child;
viewText = checkBox.getText();
} else if (switchCompatClreplaced != null && switchCompatClreplaced.isInstance(child)) {
CompoundButton switchCompat = (CompoundButton) child;
Method method;
if (switchCompat.isChecked()) {
method = child.getClreplaced().getMethod("getTextOn");
} else {
method = child.getClreplaced().getMethod("getTextOff");
}
viewText = (String) method.invoke(child);
} else if (child instanceof RadioButton) {
RadioButton radioButton = (RadioButton) child;
viewText = radioButton.getText();
} else if (child instanceof ToggleButton) {
ToggleButton toggleButton = (ToggleButton) child;
boolean isChecked = toggleButton.isChecked();
if (isChecked) {
viewText = toggleButton.getTextOn();
} else {
viewText = toggleButton.getTextOff();
}
} else if (child instanceof Button) {
Button button = (Button) child;
viewText = button.getText();
} else if (child instanceof CheckedTextView) {
CheckedTextView textView = (CheckedTextView) child;
viewText = textView.getText();
} else if (child instanceof TextView) {
TextView textView = (TextView) child;
viewText = textView.getText();
} else if (child instanceof ImageView) {
ImageView imageView = (ImageView) child;
if (!TextUtils.isEmpty(imageView.getContentDescription())) {
viewText = imageView.getContentDescription().toString();
}
}
if (!TextUtils.isEmpty(viewText)) {
stringBuilder.append(viewText.toString());
stringBuilder.append("-");
}
}
}
return stringBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
return stringBuilder.toString();
}
}
19
Source : ViewServices.java
with MIT License
from techwithtim
with MIT License
from techwithtim
public clreplaced ViewServices extends AppCompatActivity {
private Administrator activeUser;
private ArrayList<DataBaseService> services;
private static DatabaseReference databaseServices = FirebaseDatabase.getInstance().getReference("services");
ListView listViewServices;
Button back;
Button buttonAddService;
EditText createService, editService;
RadioButton rbDoctor, rbNurse, rbStaff;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_services);
services = new ArrayList<>();
listViewServices = (ListView) findViewById(R.id.serviceList);
buttonAddService = (Button) findViewById(R.id.addBTN);
createService = findViewById(R.id.serviceNameTXT);
editService = findViewById(R.id.updateService);
rbDoctor = (RadioButton) findViewById(R.id.DoctorRB);
rbNurse = (RadioButton) findViewById(R.id.NurseRB);
rbStaff = (RadioButton) findViewById(R.id.StaffRB);
// setting up the call for long press on item
listViewServices.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
DataBaseService service = services.get(i);
showUpdateDeleteDialog(service);
return true;
}
});
back = (Button) findViewById(R.id.backBtn);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
goBack();
}
});
Intent i = getIntent();
activeUser = (Administrator) i.getSerializableExtra("user");
services = (ArrayList<DataBaseService>) i.getSerializableExtra("services");
activeUser.setServices(services);
buttonAddService.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addClinicService();
}
});
databaseServices.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
services.clear();
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
DataBaseService service = postSnapshot.getValue(DataBaseService.clreplaced);
services.add(service);
}
activeUser.setServices(services);
ServiceList serviceAdapter = new ServiceList(ViewServices.this, services);
listViewServices.setAdapter(serviceAdapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
// DATABASE METHOD EXAMPLES
// Whenever you add a service you need to catch if the service already exists
// try{
// activeUser.addService("TestService1", ServiceRole.Doctor);
// }catch (IllegalArgumentException ex){
// System.out.println("Name already exists");
// }
// To delete a service
// DataBaseService service = services.get(0); <- this will be a reference to whichever service you want to delete
// activeUser.deleteService(service);
// To update a service
// DataBaseService service = services.get(0);
// activeUser.updateService(service, "new service", ServiceRole.Doctor);
}
private void showUpdateDeleteDialog(final DataBaseService service) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.update_dialog, null);
dialogBuilder.setView(dialogView);
final AlertDialog b = dialogBuilder.create();
b.show();
final Button buttonUpdate = (Button) dialogView.findViewById(R.id.buttonUpdateService);
final Button buttonDelete = (Button) dialogView.findViewById(R.id.buttonDeleteService);
final EditText updateTextName = (EditText) dialogView.findViewById(R.id.updateService);
final RadioButton dialogrbDoctor = (RadioButton) dialogView.findViewById(R.id.DoctorRB);
final RadioButton dialogrbNurse = (RadioButton) dialogView.findViewById(R.id.NurseRB);
final RadioButton dialogrbStaff = (RadioButton) dialogView.findViewById(R.id.StaffRB);
updateTextName.setText(service.getName());
if (service.getRole() == ServiceRole.Doctor) {
dialogrbDoctor.setChecked(true);
} else {
dialogrbDoctor.setChecked(false);
}
if (service.getRole() == ServiceRole.Nurse) {
dialogrbNurse.setChecked(true);
} else {
dialogrbNurse.setChecked(false);
}
if (service.getRole() == ServiceRole.Staff) {
dialogrbStaff.setChecked(true);
} else {
dialogrbStaff.setChecked(false);
}
buttonUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String updateName = updateTextName.getText().toString().trim();
if (!updateName.equals("")) {
ServiceRole role;
if (dialogrbDoctor.isChecked()) {
role = ServiceRole.Doctor;
} else if (dialogrbNurse.isChecked()) {
role = ServiceRole.Nurse;
} else {
role = ServiceRole.Staff;
}
boolean updated = updateClinicService(service, updateName, role);
if (updated) {
hideKeyboard();
b.dismiss();
}
} else {
Toast.makeText(view.getContext(), "Please enter a service name", Toast.LENGTH_LONG).show();
}
}
});
buttonDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteClinicService(service);
b.dismiss();
}
});
}
private void addClinicService() throws IllegalArgumentException {
String service = createService.getText().toString().trim();
if (!service.equals("")) {
try {
ServiceRole role;
if (rbDoctor.isChecked())
role = ServiceRole.Doctor;
else if (rbNurse.isChecked())
role = ServiceRole.Nurse;
else
role = ServiceRole.Staff;
if (service.length() <= 2) {
Toast.makeText(this, "Service Name Too Short", Toast.LENGTH_LONG).show();
} else {
activeUser.addService(service, role);
createService.getText().clear();
hideKeyboard();
}
} catch (IllegalArgumentException ex) {
Toast.makeText(this, "Service Already Exists", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(this, "Please Enter a Service Name", Toast.LENGTH_LONG).show();
}
}
private void hideKeyboard() {
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
private void deleteClinicService(DataBaseService service) {
try {
activeUser.deleteService(service);
Toast.makeText(this, "Service deleted", Toast.LENGTH_LONG).show();
} catch (IllegalArgumentException ex) {
Toast.makeText(this, "Unexpected Error Occurred", Toast.LENGTH_LONG).show();
}
}
private boolean updateClinicService(DataBaseService service, String updateName, ServiceRole role) {
boolean didUpdate = false;
try {
didUpdate = activeUser.updateService(service, updateName, role);
if (!didUpdate) {
Toast.makeText(this, "Unexpected Error Occured", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Service Updated", Toast.LENGTH_LONG).show();
}
} catch (IllegalArgumentException ex) {
Toast.makeText(this, "Service already exists", Toast.LENGTH_LONG).show();
}
return didUpdate;
}
public void goBack() {
Intent i = new Intent(this, Admin.clreplaced);
i.putExtra("user", activeUser);
i.putExtra("users", activeUser.getUsers());
i.putExtra("services", activeUser.getServices());
startActivity(i);
}
}
19
Source : SignUp.java
with MIT License
from techwithtim
with MIT License
from techwithtim
@Override
public void onClick(View v) {
RadioButton rb1;
RadioButton rb2;
rb1 = findViewById(R.id.EmployeeRB);
rb2 = findViewById(R.id.PatientRB);
switch(v.getId()) {
case R.id.createButton:
if (validateForm()) {
if (rb1.isChecked())
openEmployee();
else if (rb2.isChecked())
openPatient();
else {
Toast.makeText(getApplicationContext(), "Please Choose a Role", Toast.LENGTH_LONG).show();
}
}
break;
case R.id.backButton:
openMain();
break;
}
}
19
Source : MainActivity.java
with GNU General Public License v3.0
from StarkSoftware
with GNU General Public License v3.0
from StarkSoftware
public ArrayList<RadioButton> segmentValues() {
segmentedButtons = new ArrayList<RadioButton>();
RadioButton segmentedButton = new RadioButton(this);
segmentedButton.setText("VALUE A");
segmentedButton.setTag("A");
segmentedButtons.add(segmentedButton);
segmentedButton = new RadioButton(this);
segmentedButton.setText("VALUE B");
segmentedButton.setTag("B");
segmentedButtons.add(segmentedButton);
return segmentedButtons;
}
19
Source : AddFragment.java
with Apache License 2.0
from SoyaLeaf
with Apache License 2.0
from SoyaLeaf
public clreplaced AddFragment extends BaseFragment implements AdapterView.OnItemSelectedListener, CompoundButton.OnCheckedChangeListener, View.OnClickListener {
private String[] mName;
private EditText mEtWho;
private NumberPicker mNpMonth;
private NumberPicker mNpDay;
private boolean isLunar = false;
private OnDoneClickListener mOnDoneClickListener;
private static final NumberPicker.Formatter LUNAR_MONTH_FORMATTER = value -> LunarUtils.LUNAR_MONTH[value - 1];
private static final NumberPicker.Formatter LUNAR_DAY_FORMATTER = LunarUtils::getLunarDay;
private static final NumberPicker.Formatter NORMAL_MONTH_FORMATTER = value -> String.format(Locale.CHINA, "%d月", value);
private static final NumberPicker.Formatter NORMAL_DAY_FORMATTER = String::valueOf;
private RadioButton mRbNormal;
private RadioButton mRbLunar;
public AddFragment() {
super(R.layout.fragment_add_birth);
}
public static AddFragment newInstance() {
AddFragment fragment = new AddFragment();
return fragment;
}
@Override
protected void setupUI() {
setupSpinner();
setupNumberPicker();
setupRadioButton();
setupOther();
}
private void setupOther() {
mEtWho = findViewById(R.id.et_who);
findToolbar().setNavigationOnClickListener(this);
findViewById(R.id.ib_done).setOnClickListener(this);
}
private void setupRadioButton() {
mRbNormal = findViewById(R.id.rb_normal);
mRbNormal.setChecked(true);
mRbLunar = findViewById(R.id.rb_lunar);
mRbNormal.setOnCheckedChangeListener(this);
mRbLunar.setOnCheckedChangeListener(this);
}
private void setupNumberPicker() {
mNpMonth = findViewById(R.id.np_month);
mNpMonth.setMaxValue(12);
mNpMonth.setMinValue(1);
mNpDay = findViewById(R.id.np_day);
mNpDay.setMaxValue(30);
mNpDay.setMinValue(1);
mNpMonth.setFormatter(NORMAL_MONTH_FORMATTER);
mNpDay.setFormatter(NORMAL_DAY_FORMATTER);
mNpMonth.setOnValueChangedListener((picker, oldVal, newVal) -> {
if (isLunar) {
mNpDay.setMaxValue(30);
} else {
int monthDayCount = DayUtils.getMonthDayCount(newVal, 2000);
mNpDay.setMaxValue(monthDayCount);
}
});
try {
Method method = mNpMonth.getClreplaced().getDeclaredMethod("changeValueByOne", boolean.clreplaced);
method.setAccessible(true);
method.invoke(mNpMonth, true);
method.invoke(mNpDay, true);
} catch (Exception e) {
e.printStackTrace();
}
}
private void setupSpinner() {
Spinner spinner = findViewById(R.id.spinner_who);
mName = getResources().getStringArray(R.array.who);
spinner.setAdapter(new ArrayAdapter<>(mHostActivity, R.layout.item_who, R.id.tv, mName));
spinner.setOnItemSelectedListener(this);
}
public void setOnDoneClickListener(OnDoneClickListener onDoneClickListener) {
this.mOnDoneClickListener = onDoneClickListener;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
boolean enabled = position == mName.length - 1;
mEtWho.setEnabled(enabled);
mEtWho.setHint(mName[position]);
mEtWho.setText("");
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
isLunar = "农历".equals(buttonView.getText());
setNumberPickerFormatter();
}
}
private void setNumberPickerFormatter() {
if (isLunar) {
mNpMonth.setFormatter(LUNAR_MONTH_FORMATTER);
mNpDay.setFormatter(LUNAR_DAY_FORMATTER);
mNpDay.setMaxValue(30);
} else {
mNpMonth.setFormatter(NORMAL_MONTH_FORMATTER);
mNpDay.setFormatter(NORMAL_DAY_FORMATTER);
}
mNpMonth.postInvalidate();
mNpDay.postInvalidate();
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.ib_done:
done();
removeFragment(this);
break;
default:
removeFragment(this);
break;
}
}
private void done() {
Birthday birthday = getBirthday();
BirthdayDao birthdayDao = BirthdayDao.getInstance(mHostActivity);
birthdayDao.add(birthday);
mOnDoneClickListener.onDone(birthday);
}
@NonNull
private Birthday getBirthday() {
String who = getWho();
String when = getWhen();
Birthday birthday = new Birthday();
birthday.setWho(who);
birthday.setWhen(when);
birthday.setLunar(isLunar);
return birthday;
}
@NonNull
private String getWhen() {
String when;
int month = mNpMonth.getValue();
int day = mNpDay.getValue();
if (isLunar) {
when = LunarUtils.LUNAR_MONTH[month - 1] + LunarUtils.getLunarDay(day);
} else {
when = month + "月" + day + "日";
}
return when;
}
@NonNull
private String getWho() {
String who = mEtWho.getText().toString().trim();
if ("".equals(who)) {
who = mEtWho.getHint().toString();
}
return who;
}
public interface OnDoneClickListener {
void onDone(Birthday birthday);
}
}
19
Source : DeleteFragment.java
with Apache License 2.0
from SoyaLeaf
with Apache License 2.0
from SoyaLeaf
@Override
protected void setupUI() {
mContentView.setOnTouchListener((v, event) -> {
if (!isExiting) {
isExiting = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
exit(v, (int) event.getX(), (int) event.getY());
} else {
removeFragment(DeleteFragment.this);
}
}
return true;
});
mCircleProgressBar = findViewById(R.id.cpb);
mCircleProgressBar.setOnTouchListener(this);
RadioGroup rg = findViewById(R.id.rg);
rg.setOnCheckedChangeListener(this);
RadioButton rb = findViewById(R.id.rb_comp);
rb.setChecked(true);
}
19
Source : BoomSearchActivity.java
with Apache License 2.0
from SmartisanTech
with Apache License 2.0
from SmartisanTech
public clreplaced BoomSearchActivity extends SearchActivity {
private static final String TAG = "BoomSearchActivity";
private static final String SEARCH_WEB = "search_web";
private static final String SEARCH_DICT = "search_dict";
private static final String SEARCH_WIKI = "search_wiki";
public static final String SEARCH_TYPE = "search_type";
public static final String SEARCH_DICT_KEY = "big_bang_default_dict";
public static final int TYPE_BAIDU = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_BAIDU;
public static final int TYPE_GOOGLE = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_GOOGLE;
public static final int TYPE_BING = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_BING;
public static final int TYPE_SHENMA = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_SHENMA;
public static final int TYPE_WIKI = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_WIKI;
public static final int TYPE_BAIKE = TYPE_WIKI + 1;
public static final int TYPE_YOUDAO = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_YOUDAO;
public static final int TYPE_KINGSOFT = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_KINGSOFT;
public static final int TYPE_BINGDICT = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_BINGDICT;
public static final int TYPE_HIDICT = Settings.TEXT_BOOM_SEARCH_VALUE.TYPE_HIDICT;
private int mArrowHorrizontalOffset;
private int mSearchType;
private int mWebSearchType;
private int mDictSearchType;
private RadioButton mSearchWeb;
private RadioButton mSearchWiki;
private RadioButton mSearchDict;
@Override
protected void initContentView() {
mContext = this;
mArrowHorrizontalOffset = getResources().getDimensionPixelOffset(R.dimen.popup_arrow_horrizontal_offset);
setContentView(R.layout.boom_search_activity);
mreplacedle = (TextView) findViewById(R.id.search_replacedle);
mProgess = findViewById(R.id.search_progress);
mColse = findViewById(R.id.search_setting);
mWebView = (WebView) findViewById(R.id.search_webview);
mGoBack = (ImageView) findViewById(R.id.go_back);
mGoForward = null;
mBrowser = findViewById(R.id.goto_browser);
mSearchWeb = (RadioButton) findViewById(R.id.search_web);
mSearchWiki = (RadioButton) findViewById(R.id.search_wiki);
mSearchDict = (RadioButton) findViewById(R.id.search_dict);
mSearchType = getIntent().getIntExtra(SEARCH_TYPE, -1);
mWebSearchType = mDictSearchType = -1;
}
public void outsideClick(View v) {
finish();
}
public interface onCheckChangedListener {
public void onCheckChanged(int id);
}
@Override
protected void setupViews() {
super.setupViews();
mColse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(BoomSearchActivity.this, TextBoomSettingsActivity.clreplaced);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "error=" + e);
}
finish();
}
});
mBrowser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoBrowser();
}
});
mGoBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mWebView.canGoBack()) {
mWebView.goBack();
}
}
});
mSearchWeb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mProgess.setTranslationX(-mArrowHorrizontalOffset);
performSearch(getSearchInfo(SEARCH_WEB));
}
}
});
mSearchWeb.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final int search_type = getSearchInfo(SEARCH_WEB);
OptionPopupWindow popup = new OptionPopupWindow(BoomSearchActivity.this, R.array.search_engine_text, R.array.search_engine_icon, search_type - TYPE_BAIDU, -1, new onCheckChangedListener() {
@Override
public void onCheckChanged(int id) {
final int new_type = TYPE_BAIDU + id;
if (search_type != new_type) {
mSearchWeb.setButtonDrawable(getIconResByType(new_type));
putSearchInfo(SEARCH_WEB, new_type);
if (mSearchWeb.isChecked()) {
performSearch(new_type);
} else {
mSearchWeb.setChecked(true);
}
}
}
});
popup.show(v);
return true;
}
});
mSearchDict.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mProgess.setTranslationX(0);
performSearch(getSearchInfo(SEARCH_DICT));
}
}
});
mSearchDict.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final int search_type = getSearchInfo(SEARCH_DICT);
OptionPopupWindow popup = new OptionPopupWindow(BoomSearchActivity.this, R.array.search_dict_text, R.array.search_dict_icon, search_type - TYPE_YOUDAO, 0, new onCheckChangedListener() {
@Override
public void onCheckChanged(int id) {
final int new_type = TYPE_YOUDAO + id;
if (search_type != new_type) {
mSearchDict.setButtonDrawable(getIconResByType(new_type));
putSearchInfo(SEARCH_DICT, new_type);
if (mSearchDict.isChecked()) {
performSearch(new_type);
} else {
mSearchDict.setChecked(true);
}
}
}
});
popup.show(v);
return true;
}
});
mSearchWiki.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mProgess.setTranslationX(mArrowHorrizontalOffset);
performSearch(getSearchInfo(SEARCH_WIKI));
}
}
});
mSearchWiki.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final int search_type = getSearchInfo(SEARCH_WIKI);
OptionPopupWindow popup = new OptionPopupWindow(BoomSearchActivity.this, R.array.search_wiki_text, R.array.search_wiki_icon, search_type - TYPE_WIKI, 1, new onCheckChangedListener() {
@Override
public void onCheckChanged(int id) {
final int new_type = TYPE_WIKI + id;
if (search_type != new_type) {
mSearchWiki.setButtonDrawable(getIconResByType(new_type));
putSearchInfo(SEARCH_WIKI, new_type);
if (mSearchWiki.isChecked()) {
performSearch(new_type);
} else {
mSearchWiki.setChecked(true);
}
}
}
});
popup.show(v);
return true;
}
});
}
@Override
protected void onResume() {
super.onResume();
final int webType = Settings.Global.getInt(getContentResolver(), Settings.Global.TEXT_BOOM_SEARCH_METHOD, TYPE_SHENMA);
final int dictType = Settings.Global.getInt(getContentResolver(), SEARCH_DICT_KEY, TYPE_BINGDICT);
if (mWebSearchType == -1)
mWebSearchType = webType;
if (mDictSearchType == -1)
mDictSearchType = dictType;
if (mSearchType < TYPE_YOUDAO) {
if (webType != mWebSearchType) {
mSearchType = mWebSearchType = webType;
}
if (mSearchType < TYPE_WIKI) {
putSearchInfo(SEARCH_WEB, mSearchType);
mSearchWeb.setChecked(true);
} else if (mSearchType < TYPE_YOUDAO) {
putSearchInfo(SEARCH_WIKI, mSearchType);
mSearchWiki.setChecked(true);
}
if (dictType != mDictSearchType) {
mDictSearchType = dictType;
mSearchDict.setButtonDrawable(getIconResByType(dictType));
putSearchInfo(SEARCH_DICT, dictType);
}
} else {
if (dictType != mDictSearchType) {
mSearchType = mDictSearchType = dictType;
}
putSearchInfo(SEARCH_DICT, mSearchType);
mSearchDict.setChecked(true);
if (webType != mWebSearchType) {
mWebSearchType = webType;
if (webType < TYPE_WIKI) {
mSearchWeb.setButtonDrawable(getIconResByType(webType));
putSearchInfo(SEARCH_WEB, webType);
} else if (webType < TYPE_YOUDAO) {
mSearchWiki.setButtonDrawable(getIconResByType(webType));
putSearchInfo(SEARCH_WIKI, webType);
}
}
}
mSearchWeb.setButtonDrawable(getIconResByType(getSearchInfo(SEARCH_WEB)));
mSearchDict.setButtonDrawable(getIconResByType(getSearchInfo(SEARCH_DICT)));
mSearchWiki.setButtonDrawable(getIconResByType(getSearchInfo(SEARCH_WIKI)));
}
private String getSearchInfoByType(int type) {
switch(type) {
case TYPE_BAIDU:
return "Baidu";
case TYPE_GOOGLE:
return "Google";
case TYPE_BING:
return "Bing";
case TYPE_SHENMA:
return "Shenma";
case TYPE_WIKI:
return "Hudong Baike";
case TYPE_BAIKE:
return "Baidu Baike";
case TYPE_YOUDAO:
return "Youdao Dictionary";
case TYPE_KINGSOFT:
return "Iciba";
case TYPE_BINGDICT:
return "Bing Dictionary";
case TYPE_HIDICT:
return "DICT.CN";
default:
return "Unknown";
}
}
@Override
protected void onStop() {
super.onStop();
JSONArray jsonArray = new JSONArray();
jsonArray.put(getSearchInfoByType(getSearchInfo(SEARCH_WEB)));
jsonArray.put(getSearchInfoByType(getSearchInfo(SEARCH_DICT)));
jsonArray.put(getSearchInfoByType(getSearchInfo(SEARCH_WIKI)));
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// Remove slop for shadow
if (event.getAction() == MotionEvent.ACTION_DOWN) {
final Window window = getWindow();
final int x = (int) event.getX();
final int y = (int) event.getY();
final View decorView = window.getDecorView();
if (x < 0 || x > decorView.getWidth() || y < 0 || y > decorView.getHeight()) {
if (window.peekDecorView() != null) {
finish();
return true;
}
}
}
return false;
}
@Override
protected String getOriUrl() {
switch(mSearchType) {
case TYPE_GOOGLE:
return "https://www.google.com/search?q=" + mSearchText;
case TYPE_BING:
return "https://www.bing.com/search?q=" + mSearchText;
case TYPE_SHENMA:
return "http://m.yz.sm.cn/s?q=" + mSearchText;
case TYPE_WIKI:
return "http://www.baike.com/gwiki/" + mSearchText;
case TYPE_BAIKE:
return "http://wapbaike.baidu.com/search/word?word=" + mSearchText;
case TYPE_YOUDAO:
return "http://m.youdao.com/dict?q=" + mSearchText;
case TYPE_KINGSOFT:
return "http://www.iciba.com/" + mSearchText;
case TYPE_BINGDICT:
return "http://cn.bing.com/dict/?q=" + mSearchText;
case TYPE_HIDICT:
return "http://m.dict.cn/" + mSearchText;
default:
return "https://www.baidu.com/s?wd=" + mSearchText;
}
}
private int getIconResByType(int type) {
if (type == TYPE_BAIDU) {
return R.drawable.boom_win_search_baidu;
} else if (type == TYPE_GOOGLE) {
return R.drawable.boom_win_search_google;
} else if (type == TYPE_BING) {
return R.drawable.boom_win_search_bing;
} else if (type == TYPE_SHENMA) {
return R.drawable.boom_win_search_shenma;
} else if (type == TYPE_WIKI) {
return R.drawable.boom_win_search_hudongdict;
} else if (type == TYPE_BAIKE) {
return R.drawable.boom_win_search_baike;
} else if (type == TYPE_YOUDAO) {
return R.drawable.boom_win_search_youdao;
} else if (type == TYPE_KINGSOFT) {
return R.drawable.boom_win_search_kingsoft;
} else if (type == TYPE_BINGDICT) {
return R.drawable.boom_win_search_bingdict;
} else if (type == TYPE_HIDICT) {
return R.drawable.boom_win_search_hidict;
}
return 0;
}
private void performSearch(int type) {
mSearchType = type;
mWebView.clearHistory();
mFirstPage = true;
mWebView.loadUrl(getOriUrl());
}
private int getSearchInfo(String key) {
SharedPreferences preferences = getSharedPreferences("setting", Context.MODE_PRIVATE);
int defaultValue = TYPE_SHENMA;
if (key.equals(SEARCH_DICT)) {
defaultValue = TYPE_BINGDICT;
} else if (key.equals(SEARCH_WIKI)) {
defaultValue = TYPE_WIKI;
}
return preferences.getInt(key, defaultValue);
}
private void putSearchInfo(String key, int value) {
SharedPreferences preferences = getSharedPreferences("setting", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(key, value);
editor.commit();
}
@Override
protected void loadUrl() {
}
}
19
Source : LanguageDialog.java
with GNU General Public License v3.0
from skewyapp
with GNU General Public License v3.0
from skewyapp
public clreplaced LanguageDialog extends DialogFragment {
private RadioButton radioButtonEnglish;
private RadioGroup radioGroupLanguages;
private RadioButton radioButton;
private String languageSelection;
private LanguageDialogListener mLanguageDialogListener;
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity());
LayoutInflater mInflater = getActivity().getLayoutInflater();
final View v = mInflater.inflate(R.layout.dialog_language, null);
radioButtonEnglish = v.findViewById(R.id.radio_button_language_english);
radioGroupLanguages = v.findViewById(R.id.radio_group_languages);
// Preplaceding the view to the dialog which is build
mBuilder.setView(v).setreplacedle("Select language").setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// DO nothing on cancel
}
}).setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Here all the stuff needs to be pulled out and preplaceded to the activity/Fragment
// Underlying activty gets preplaceded the input
// Identify which radioButton is checked
int radioId = radioGroupLanguages.getCheckedRadioButtonId();
radioButton = v.findViewById(radioId);
if (radioButton != null) {
// If user does not select anything ... do nothing
String language = radioButton.getText().toString();
// Change Locale
switch(language) {
case "English":
languageSelection = "en";
break;
case "German":
languageSelection = "de";
break;
default:
break;
}
mLanguageDialogListener.applyLanguageDialogInput(languageSelection);
}
}
});
return mBuilder.create();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mLanguageDialogListener = (LanguageDialogListener) context;
} catch (ClreplacedCastException e) {
// This will throw if no SlmDialaogListner is implemented in Activity
throw new ClreplacedCastException(context.toString() + "must implement LanguageDialogListener");
}
}
public interface LanguageDialogListener {
// All input parameters must be preplaceded here
void applyLanguageDialogInput(String languageSelection);
}
}
19
Source : ARadioGroup.java
with Apache License 2.0
from shiburagi
with Apache License 2.0
from shiburagi
/**
* Created by Shiburagi on 23/06/2016.
*/
public clreplaced ARadioGroup extends RadioGroup {
private static final String TAG = ARadioGroup.clreplaced.getSimpleName();
private ArrayList<RadioButton> radioButtons;
private OnCheckedChangeListener listener;
private RadioButton selected;
private int selectedId;
private boolean trigger;
public ARadioGroup(Context context) {
super(context);
init(context, null);
}
public ARadioGroup(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
radioButtons = new ArrayList<>();
search(context, this);
Log.d(TAG, "Size : " + radioButtons.size() + ", " + getChildCount());
}
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
Log.d(TAG, "addView");
search(getContext(), child);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
Log.d(TAG, "onLayout() : " + selected);
trigger = false;
if (selected != null) {
selected.setChecked(true);
// radioButtons.get(selectedId).setChecked(true);
}
trigger = true;
}
private void search(Context context, View view) {
if (view instanceof RadioButton) {
final RadioButton radioButton = (RadioButton) view;
radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
clearCheck(radioButton);
selected = radioButton;
if (trigger)
listener.onCheckedChanged(ARadioGroup.this, buttonView.getId());
}
}
});
radioButtons.add(radioButton);
} else if (view instanceof ViewGroup) {
search(context, (ViewGroup) view);
}
}
private void search(Context context, ViewGroup viewGroup) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View view = viewGroup.getChildAt(i);
search(context, view);
}
}
private void clearCheck(RadioButton radioButton) {
for (RadioButton _radioButton : radioButtons) {
if (radioButton != _radioButton)
_radioButton.setChecked(false);
}
}
@Override
public void clearCheck() {
for (RadioButton radioButton : radioButtons) {
radioButton.setChecked(false);
}
}
@Override
public void setOnCheckedChangeListener(final OnCheckedChangeListener listener) {
this.listener = listener;
super.setOnCheckedChangeListener(listener);
}
public RadioButton getSelected() {
return selected;
}
}
19
Source : AdvancedOptionsDialogFragment.java
with Apache License 2.0
from shazam
with Apache License 2.0
from shazam
@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);
}
}
19
Source : RadioBoxesFragment.java
with Apache License 2.0
from ShashiPrasadKushwaha
with Apache License 2.0
from ShashiPrasadKushwaha
private void saveActionsOfRadioBox() {
for (int i = 0; i < radioButtonArrayList.size(); i++) {
if (i == clickedRadioButtonPosition) {
RadioButton radioButton = radioButtonArrayList.get(i);
if (radioButton.isChecked()) {
atLeastOneChecked = true;
String cbPosition = String.valueOf(radioButtonArrayList.indexOf(radioButton));
String[] data = new String[] { "1", questionId, cbPosition };
insertChoiceInDatabase(data);
} else {
String cbPosition = String.valueOf(radioButtonArrayList.indexOf(radioButton));
String[] data = new String[] { "0", questionId, cbPosition };
insertChoiceInDatabase(data);
}
}
}
if (atLeastOneChecked) {
nextOrFinishButton.setEnabled(true);
} else {
nextOrFinishButton.setEnabled(false);
}
}
19
Source : RadioBoxesFragment.java
with Apache License 2.0
from ShashiPrasadKushwaha
with Apache License 2.0
from ShashiPrasadKushwaha
/*This method get called only when the fragment get visible, and here states of Radio Button(s) retained*/
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
screenVisible = true;
for (int i = 0; i < radioButtonArrayList.size(); i++) {
RadioButton radioButton = radioButtonArrayList.get(i);
String cbPosition = String.valueOf(i);
String[] data = new String[] { questionId, cbPosition };
Observable.just(data).map(this::getTheStateOfRadioBox).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String s) {
qState = s;
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
if (qState.equals("1")) {
radioButton.setChecked(true);
} else {
radioButton.setChecked(false);
}
}
});
}
}
}
19
Source : RadioButtonPreference.java
with Apache License 2.0
from sergchil
with Apache License 2.0
from sergchil
/**
* Radio Button preference
*/
public clreplaced RadioButtonPreference extends Preference {
interface OnRadioButtonClickedListener {
/**
* Called when this preference needs to be saved its state.
*
* @param preference This preference.
*/
public void onRadioButtonClicked(RadioButtonPreference preference);
}
private boolean mIsSelected;
private RadioButton mRadioButton;
private OnRadioButtonClickedListener mListener;
private final View.OnClickListener mClickListener = new View.OnClickListener() {
@Override
public void onClick(final View v) {
callListenerOnRadioButtonClicked();
}
};
public RadioButtonPreference(final Context context) {
this(context, null);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
public void setOnRadioButtonClickedListener(final OnRadioButtonClickedListener listener) {
mListener = listener;
}
void callListenerOnRadioButtonClicked() {
if (mListener != null) {
mListener.onRadioButtonClicked(this);
}
}
@Override
protected void onBindView(final View view) {
super.onBindView(view);
mRadioButton = (RadioButton) view.findViewById(R.id.radio_button);
mRadioButton.setChecked(mIsSelected);
mRadioButton.setOnClickListener(mClickListener);
view.setOnClickListener(mClickListener);
}
public boolean isSelected() {
return mIsSelected;
}
public void setSelected(final boolean selected) {
if (selected == mIsSelected) {
return;
}
mIsSelected = selected;
if (mRadioButton != null) {
mRadioButton.setChecked(selected);
}
notifyChanged();
}
}
19
Source : PostDetailPresenter.java
with Apache License 2.0
from scatl
with Apache License 2.0
from scatl
/**
* author: sca_tl
* description: 举报
*/
public void showReportDialog(Context context, int id, String type) {
final View report_view = LayoutInflater.from(context).inflate(R.layout.dialog_report, new RelativeLayout(context));
final AppCompatEditText editText = report_view.findViewById(R.id.dialog_report_text);
final RadioGroup radioGroup = report_view.findViewById(R.id.dialog_report_radio_group);
final AlertDialog report_dialog = new AlertDialog.Builder(context).setPositiveButton("确认举报", null).setNegativeButton("取消", null).setView(report_view).setreplacedle("举报").create();
report_dialog.setOnShowListener(dialogInterface -> {
Button p = report_dialog.getButton(AlertDialog.BUTTON_POSITIVE);
p.setOnClickListener(view -> {
RadioButton radioButton = report_view.findViewById(radioGroup.getCheckedRadioButtonId());
String s = radioButton.getText().toString();
String msg = "[" + s + "]" + editText.getText().toString();
report(type, msg, id, context);
report_dialog.dismiss();
});
});
report_dialog.show();
}
19
Source : RadioButtonPreference.java
with Apache License 2.0
from rkkr
with Apache License 2.0
from rkkr
/**
* Radio Button preference
*/
public clreplaced RadioButtonPreference extends Preference {
interface OnRadioButtonClickedListener {
/**
* Called when this preference needs to be saved its state.
*
* @param preference This preference.
*/
void onRadioButtonClicked(RadioButtonPreference preference);
}
private boolean mIsSelected;
private RadioButton mRadioButton;
private OnRadioButtonClickedListener mListener;
private final View.OnClickListener mClickListener = new View.OnClickListener() {
@Override
public void onClick(final View v) {
callListenerOnRadioButtonClicked();
}
};
public RadioButtonPreference(final Context context) {
this(context, null);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}
public RadioButtonPreference(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWidgetLayoutResource(R.layout.radio_button_preference_widget);
}
public void setOnRadioButtonClickedListener(final OnRadioButtonClickedListener listener) {
mListener = listener;
}
void callListenerOnRadioButtonClicked() {
if (mListener != null) {
mListener.onRadioButtonClicked(this);
}
}
@Override
protected void onBindView(final View view) {
super.onBindView(view);
mRadioButton = (RadioButton) view.findViewById(R.id.radio_button);
mRadioButton.setChecked(mIsSelected);
mRadioButton.setOnClickListener(mClickListener);
view.setOnClickListener(mClickListener);
}
public void setSelected(final boolean selected) {
if (selected == mIsSelected) {
return;
}
mIsSelected = selected;
if (mRadioButton != null) {
mRadioButton.setChecked(selected);
}
notifyChanged();
}
}
19
Source : RtmpActivity.java
with Apache License 2.0
from ricohapi
with Apache License 2.0
from ricohapi
private void prepareOptionsMenuViews() {
drawerLayout = findViewById(R.id.activity_custom);
navigationView = findViewById(R.id.nv_rtp);
navigationView.inflateMenu(R.menu.options_rtmp);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.rtsp_streamer, R.string.rtsp_streamer) {
public void onDrawerOpened(View drawerView) {
actionBarDrawerToggle.syncState();
lastVideoBitrate = etVideoBitrate.getText().toString();
}
public void onDrawerClosed(View view) {
actionBarDrawerToggle.syncState();
if (!lastVideoBitrate.equals(etVideoBitrate.getText().toString()) && rtmpCamera1.isStreaming()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int bitrate = Integer.parseInt(etVideoBitrate.getText().toString()) * 1024;
rtmpCamera1.setVideoBitrateOnFly(bitrate);
Toast.makeText(RtmpActivity.this, "New bitrate: " + bitrate, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(RtmpActivity.this, "Bitrate on fly ignored, Required min API 19", Toast.LENGTH_SHORT).show();
}
}
}
};
drawerLayout.addDrawerListener(actionBarDrawerToggle);
// checkboxs
cbEchoCanceler = (CheckBox) navigationView.getMenu().findItem(R.id.cb_echo_canceler).getActionView();
cbNoiseSuppressor = (CheckBox) navigationView.getMenu().findItem(R.id.cb_noise_suppressor).getActionView();
cbHardwareRotation = (CheckBox) navigationView.getMenu().findItem(R.id.cb_hardware_rotation).getActionView();
// radiobuttons
RadioButton rbTcp = (RadioButton) navigationView.getMenu().findItem(R.id.rb_tcp).getActionView();
rgChannel = (RadioGroup) navigationView.getMenu().findItem(R.id.channel).getActionView();
rbTcp.setChecked(true);
// spinners
spResolution = (Spinner) navigationView.getMenu().findItem(R.id.sp_resolution).getActionView();
spOrientation = (Spinner) navigationView.getMenu().findItem(R.id.sp_orientation).getActionView();
ArrayAdapter<Integer> orientationAdapter = new ArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item);
orientationAdapter.addAll(orientations);
spOrientation.setAdapter(orientationAdapter);
spOrientation.setSelection(0);
ArrayAdapter<String> resolutionAdapter = new ArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item);
List<String> list = new ArrayList<>();
for (Camera.Size size : rtmpCamera1.getResolutionsBack()) {
list.add(size.width + "X" + size.height);
}
resolutionAdapter.addAll(list);
spResolution.setAdapter(resolutionAdapter);
// edittexts
etVideoBitrate = (EditText) navigationView.getMenu().findItem(R.id.et_video_bitrate).getActionView();
etFps = (EditText) navigationView.getMenu().findItem(R.id.et_fps).getActionView();
etAudioBitrate = (EditText) navigationView.getMenu().findItem(R.id.et_audio_bitrate).getActionView();
etSampleRate = (EditText) navigationView.getMenu().findItem(R.id.et_samplerate).getActionView();
etVideoBitrate.setText("2500");
etFps.setText("30");
etAudioBitrate.setText("128");
etSampleRate.setText("44100");
etWowzaUser = (EditText) navigationView.getMenu().findItem(R.id.et_wowza_user).getActionView();
etWowzaPreplacedword = (EditText) navigationView.getMenu().findItem(R.id.et_wowza_preplacedword).getActionView();
}
19
Source : ZenRuleNameDialog.java
with MIT License
from ric96
with MIT License
from ric96
private RuleInfo selectedRuleInfo() {
final int id = mTypes.getCheckedRadioButtonId();
if (id == -1)
return null;
final RadioButton rb = (RadioButton) mTypes.findViewById(id);
return (RuleInfo) rb.getTag();
}
19
Source : ValueAnimationActivity.java
with Apache License 2.0
from REBOOTERS
with Apache License 2.0
from REBOOTERS
/**
* Created by rookie on 2016/8/9.
*/
public clreplaced ValueAnimationActivity extends BaseActivity implements View.OnClickListener {
PointAnimView view;
//
private RadioButton rb1, rb2, rb3, rb4, rb5, rb6, rb7;
private int type;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_value_animation);
}
@Override
public void initView() {
view = (PointAnimView) findViewById(R.id.view);
findViewById(R.id.start).setOnClickListener(this);
findViewById(R.id.stop).setOnClickListener(this);
rb1 = (RadioButton) findViewById(R.id.rb1);
rb2 = (RadioButton) findViewById(R.id.rb2);
rb3 = (RadioButton) findViewById(R.id.rb3);
rb4 = (RadioButton) findViewById(R.id.rb4);
rb5 = (RadioButton) findViewById(R.id.rb5);
rb6 = (RadioButton) findViewById(R.id.rb6);
rb7 = (RadioButton) findViewById(R.id.rb7);
}
@Override
protected void onStop() {
super.onStop();
if (view != null) {
view.stopAnimation();
}
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.start:
if (view != null) {
if (rb1.isChecked()) {
type = 1;
} else if (rb2.isChecked()) {
type = 2;
} else if (rb3.isChecked()) {
type = 3;
} else if (rb4.isChecked()) {
type = 4;
} else if (rb5.isChecked()) {
type = 5;
} else if (rb6.isChecked()) {
type = 6;
} else if (rb7.isChecked()) {
type = 7;
} else {
type = 0;
}
view.stopAnimation();
view.setInterpolatorType(type);
view.StartAnimation();
}
break;
case R.id.stop:
if (view != null) {
view.stopAnimation();
}
break;
default:
break;
}
}
}
19
Source : SearchFragment.java
with GNU General Public License v3.0
from rascarlo
with GNU General Public License v3.0
from rascarlo
private void setUpKeywords() {
RadioButton radioButtonNameOrDescription = radioGroupKeywords.findViewById(R.id.search_radio_button_name_or_description);
RadioButton radioButtonExactName = radioGroupKeywords.findViewById(R.id.search_radio_button_exact_name);
RadioButton radioButtonDescription = radioGroupKeywords.findViewById(R.id.search_radio_button_description);
String sharedPreferenceKeywords = ArchPackagesSharedPreferences.getSharedPreferenceString(context, getString(R.string.key_keywords), getString(R.string.key_keywords_name_or_description));
if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_name_or_description))) {
radioButtonNameOrDescription.setChecked(true);
} else if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_exact_name))) {
radioButtonExactName.setChecked(true);
} else if (TextUtils.equals(sharedPreferenceKeywords, getString(R.string.key_keywords_description))) {
radioButtonDescription.setChecked(true);
} else {
radioButtonNameOrDescription.setChecked(true);
}
}
19
Source : SearchFragment.java
with GNU General Public License v3.0
from rascarlo
with GNU General Public License v3.0
from rascarlo
private void setUpFlagged() {
RadioButton radioButtonFlagAll = radioGroupFlag.findViewById(R.id.search_radio_button_flag_all);
RadioButton radioButtonFlagFlagged = radioGroupFlag.findViewById(R.id.search_radio_button_flag_flagged);
RadioButton radioButtonFlagNotFlagged = radioGroupFlag.findViewById(R.id.search_radio_button_flag_not_flagged);
String sharedPreferenceFlag = ArchPackagesSharedPreferences.getSharedPreferenceString(context, getString(R.string.key_flag), getString(R.string.key_flag_flagged_all));
if (TextUtils.equals(sharedPreferenceFlag, getString(R.string.key_flag_flagged_all))) {
radioButtonFlagAll.setChecked(true);
} else if (TextUtils.equals(sharedPreferenceFlag, getString(R.string.key_flag_flagged))) {
radioButtonFlagFlagged.setChecked(true);
} else if (TextUtils.equals(sharedPreferenceFlag, getString(R.string.key_flag_not_flagged))) {
radioButtonFlagNotFlagged.setChecked(true);
} else {
radioButtonFlagAll.setChecked(true);
}
}
19
Source : TintHelper.java
with Apache License 2.0
from RajneeshSingh007
with Apache License 2.0
from RajneeshSingh007
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
ATEUtil.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);
}
}
19
Source : SpecialHolder.java
with GNU Affero General Public License v3.0
from qwsem
with GNU Affero General Public License v3.0
from qwsem
public void cancleClickAble(int type) {
if (DAOFANG_CLlick_TYPE == type) {
final RadioButton rb_time_daofang = (RadioButton) v.findViewById(R.id.btn_time_daofang);
rb_time_daofang.setEnabled(false);
v.findViewById(R.id.btn_time_daofang).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show("该视频不能进行倒放");
}
});
}
}
See More Examples