public void onResume() { // reset to default AppCompatRadioButton activeRadioButton = this.activeRadioButton; clearCheckedChildren(); this.activeRadioButton = activeRadioButton; this.activeRadioButton.setChecked(true); }
@Override public void onClick(View v) { final boolean started = v.getTag() != null; if (started) { controller.stop(); } else { v.setTag(new Object()); actionTv.setText(R.string.cancel); // to start controller.start(serialRb.isChecked()); adapter.notifyDataSetChanged(); serialRb.setEnabled(false); parallelRb.setEnabled(false); deleteActionView.setEnabled(false); deleteActionView.setTag(deleteActionView.getCardElevation()); deleteActionView.setCardElevation(0); deleteActionTv.setEnabled(false); } } });
@OnClick(R.id.rd_togrg) void GrgSelect(){ if(rdTojalali.isChecked()){ rdTojalali.setChecked(false); } } @OnClick(R.id.btn_calc) void calc(){
AppCompatRadioButton tempButton = new AppCompatRadioButton(context); tempButton.setTextColor(ColorUtil.getColor(context, R.attr.colorPrimary)); tempButton.setText(time); tempButton.setId(i); rg.addView(tempButton, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); if (at != null) at.setChecked(true); at = (AppCompatRadioButton) termRg.getChildAt(0); if (at != null) at.setChecked(true);
AppCompatRadioButton arb = new AppCompatRadioButton(getActivity()); ViewGroup.LayoutParams.WRAP_CONTENT); arb.setLayoutParams(params); arb.setId(i); arb.setTextColor(getResources().getColor(themeColorArray[i])); arb.setText(themeNameArray[i]); arb.setTextSize(16); arb.setPadding(0, margin / 2, 0, margin / 2); radioGroup.addView(arb);
normalButton.setId(0); normalButton.setText(R.string.font_default); normalButton.setChecked(preference == null || preference.length() == 0); group.addView(normalButton); button.setId(i + 1); button.setText(item.replace(".ttf", "")); button.setTag(item); try { button.setTypeface(Typeface.createFromAsset(getContext().getAssets(), item)); } catch (Exception e) { continue; button.setChecked(preference != null && preference.equals(item)); group.addView(button);
private void setQuestionItem(int pos, AppCompatRadioButton rb, ViewGroup.LayoutParams lp, ColorStateList csl){ rb.setLayoutParams(lp); rb.setTag(pos); rb.setTextColor(mTextColor); rb.setTextSize(mTextSize); rb.setText(mQuestionsArray[pos]); rb.setOnClickListener(onQuestionItemListener); rb.setSupportButtonTintList(csl); mQuestionRBtnsList.add(rb); }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { // Allow super to try and create a view first final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // If we're running pre-L, we need to 'inject' our tint aware Views in place of the // standard framework versions switch (name) { case "EditText": return new AppCompatEditText(this, attrs); case "Spinner": return new AppCompatSpinner(this, attrs); case "CheckBox": return new AppCompatCheckBox(this, attrs); case "RadioButton": return new AppCompatRadioButton(this, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this, attrs); } } Api.fixFolderPermissionsAsync(context); return null; }
IconStyleData style = styles.get(position); holder.button.setText(style.name); holder.button.setChecked(style.equals(this.style));
@Override public boolean isChecked() { return super.isChecked(); }
@Override public void setOnClickListener(OnClickListener l) { super.setOnClickListener(new SingleClickListener(l)); }
@OnClick(R.id.rd_togrg) void GrgSelect(){ if(rdTojalali.isChecked()){ rdTojalali.setChecked(false); } } @OnClick(R.id.btn_calc) void calc(){
private void setQuestionsGroupView(){ LinearLayout.LayoutParams rglp = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams rblp = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); mQuestionsGroup.setLayoutParams(rglp); ColorStateList colorStateList = new ColorStateList( new int[][]{ new int[]{mRadioBtnColor}, new int[]{mRadioBtnColor} }, new int[]{mRadioBtnColor, mRadioBtnColor} ); for (int i = 0; i < mQuestionsArray.length; i++) { AppCompatRadioButton rb = new AppCompatRadioButton(mContext); setQuestionItem(i, rb, rblp, colorStateList); mQuestionsGroup.addView(rb); } }
@OnClick(R.id.btn_calc) void calc(){ if(edtDay.getText().toString().equals("") || edtDay.getText().toString().equals("") || edtDay.getText().toString().equals("")){ Toast.makeText(this,getString(R.string.allFieldRequred),Toast.LENGTH_LONG).show(); return; } int day = Integer.parseInt(edtDay.getText().toString()); int month = Integer.parseInt(edtMonth.getText().toString()); int year = Integer.parseInt(edtYear.getText().toString()); if(day > 31){ Toast.makeText(this,getString(R.string.dayWrong),Toast.LENGTH_LONG).show(); edtDay.setText(""+31); return; } if(month > 12){ Toast.makeText(this,getString(R.string.monthWrong),Toast.LENGTH_LONG).show(); edtMonth.setText(""+12); return; } PersianDate date; if(rdTojalali.isChecked()){ date = new PersianDate().initJalaliDate(year,month,day); Date grgDate = date.toDate(); txtResult.setText(new SimpleDateFormat("EEEE dd MMMM yyyy").format(grgDate)); }else{ date = new PersianDate().initGrgDate(year,month,day); txtResult.setText(formater.format(date)); } }
final AppCompatRadioButton rb = (AppCompatRadioButton) view; if ( activeRadioButton != null ) { activeRadioButton.setChecked(false); rb.setChecked(true); activeRadioButton = rb;
@OnClick(R.id.rd_tojalali) void JalaliSelect(){ if(rdTogrg.isChecked()){ rdTogrg.setChecked(false); } } @OnClick(R.id.rd_togrg) void GrgSelect(){
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { // Allow super to try and create a view first final View result = super.onCreateView(name, context, attrs); if (result != null) { return result; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // If we're running pre-L, we need to 'inject' our tint aware Views in place of the // standard framework versions switch (name) { case "EditText": return new AppCompatEditText(this, attrs); case "Spinner": return new AppCompatSpinner(this, attrs); case "CheckBox": return new AppCompatCheckBox(this, attrs); case "RadioButton": return new AppCompatRadioButton(this, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(this, attrs); } } return null; }
@OnClick(R.id.btn_calc) void calc(){ if(edtDay.getText().toString().equals("") || edtDay.getText().toString().equals("") || edtDay.getText().toString().equals("")){ Toast.makeText(this,getString(R.string.allFieldRequred),Toast.LENGTH_LONG).show(); return; } int day = Integer.parseInt(edtDay.getText().toString()); int month = Integer.parseInt(edtMonth.getText().toString()); int year = Integer.parseInt(edtYear.getText().toString()); if(day > 31){ Toast.makeText(this,getString(R.string.dayWrong),Toast.LENGTH_LONG).show(); edtDay.setText(""+31); return; } if(month > 12){ Toast.makeText(this,getString(R.string.monthWrong),Toast.LENGTH_LONG).show(); edtMonth.setText(""+12); return; } PersianDate date; if(rdTojalali.isChecked()){ date = new PersianDate().initJalaliDate(year,month,day); long[] age = date.untilToday(); txtResult.setText("" + age[0] + " روز " + age[1] + " ساعت " + age[2] + " دقیقه " + age[3] + " ثانیه"); }else{ date = new PersianDate().initGrgDate(year,month,day); long[] age = date.untilToday(); txtResult.setText("" + age[0] + " روز " + age[1] + " ساعت " + age[2] + " دقیقه " + age[3] + " ثانیه"); } }
private void clearCheckedChildren() { for (int i = 0; i < getChildCount(); i++) { if (getChildAt(i) instanceof AppCompatRadioButton) { ((AppCompatRadioButton) getChildAt(i)).setChecked(false); } } }
@OnClick(R.id.rd_tojalali) void JalaliSelect(){ if(rdTogrg.isChecked()){ rdTogrg.setChecked(false); } } @OnClick(R.id.rd_togrg) void GrgSelect(){