public void onRadioButtonClicked(View view) { boolean checked = ((RadioButton) view).isChecked(); EditText editItem = (EditText) findViewById(R.id.etEditItem); // Check which radio button was clicked switch (view.getId()) { case R.id.rbPriority3: if (checked) { itemPriority = CommonConstants.STANDARD_PRIORITY; editItem.setTextColor(editItem.getResources().getColor(R.color.standard_priority)); } break; case R.id.rbPriority2: if (checked) { itemPriority = CommonConstants.ELEVATED_PRIORITY; editItem.setTextColor(editItem.getResources().getColor(R.color.elevated_priority)); } break; case R.id.rbPriority1: if (checked) { itemPriority = CommonConstants.HIGH_PRIORITY; editItem.setTextColor(editItem.getResources().getColor(R.color.high_priority)); } break; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); prefs = PreferenceManager.getDefaultSharedPreferences(this); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { getSupportActionBar().setDisplayShowHomeEnabled(true); actionBar.setLogo(R.mipmap.cp_logo); getSupportActionBar().setDisplayUseLogoEnabled(true); } EditText editItem = (EditText) findViewById(R.id.etEditItem); editItem.setText(getIntent().getStringExtra("itemText")); editItem.setSelection(editItem.getText().length()); SimpleDateFormat date = new SimpleDateFormat("MM/d/yyyy"); dueDate = getIntent().getLongExtra("dueDate", System.currentTimeMillis()); Button dueDateText = (Button) findViewById(R.id.btCalendar); dueDateText.setText(date.format(new Date(dueDate))); RadioButton radioButton3 = (RadioButton) findViewById(R.id.rbPriority3); radioButton3.setText(prefs.getString("priority_default", "Just do it")); RadioButton radioButton2 = (RadioButton) findViewById(R.id.rbPriority2); radioButton2.setText(prefs.getString("priority_high", "Get it done!")); RadioButton radioButton1 = (RadioButton) findViewById(R.id.rbPriority1); radioButton1.setText(prefs.getString("priority_highest", "Life Matter")); itemPriority = Integer.parseInt(getIntent().getStringExtra("priority")); switch (itemPriority) { case CommonConstants.STANDARD_PRIORITY: { radioButton3.performClick(); editItem.setTextColor(editItem.getResources().getColor(R.color.standard_priority)); break; } case CommonConstants.ELEVATED_PRIORITY: { radioButton2.performClick(); editItem.setTextColor(editItem.getResources().getColor(R.color.elevated_priority)); break; } case CommonConstants.HIGH_PRIORITY: { radioButton1.performClick(); editItem.setTextColor(editItem.getResources().getColor(R.color.high_priority)); break; } } }
public final void showDialog() { EditText localEditText; if (this.gFV != null) localEditText = this.gFV; while (true) { ViewGroup.LayoutParams localLayoutParams = localEditText.getLayoutParams(); if ((localLayoutParams instanceof ViewGroup.MarginLayoutParams)) { ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams) localLayoutParams; int i = localEditText.getResources().getDimensionPixelSize(g.aaQ); localMarginLayoutParams.leftMargin = i; localMarginLayoutParams.rightMargin = i; localMarginLayoutParams.topMargin = i; localMarginLayoutParams.bottomMargin = i; } if (localEditText.getParent() != null) ((ViewGroup) localEditText.getParent()).removeView(localEditText); this.dpV = h.a( getContext(), getTitle().toString(), localEditText, a.m(getContext(), n.bee), a.m(getContext(), n.bds), new k(this, localEditText), new l(this)); return; localEditText = new EditText(getContext()); localEditText.setLayoutParams(new ViewGroup.LayoutParams(-1, -2)); localEditText.setSingleLine(true); localEditText.setText(this.value); } }
/** * A specialized TextWatcher designed specifically for converting EditText values to a * pretty-print string currency value. * * @param textBox The EditText box to which this TextWatcher is being applied. Used for replacing * user-entered text with formatted text as well as handling cursor position for inputting * monetary values */ public CurrencyTextWatcher(EditText textBox) { editText = textBox; lastGoodInput = ""; ignoreIteration = false; locale = editText.getResources().getConfiguration().locale; try { currency = Currency.getInstance(locale); } catch (IllegalArgumentException e) { currency = Currency.getInstance(Locale.US); } currencyFormatter = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale); // Different countries use different fractional values for denominations (0.999 <x> vs. 0.99 // cents), therefore this must be defined at runtime CURRENCY_DECIMAL_DIVISOR = (int) Math.pow(10, currency.getDefaultFractionDigits()); }
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { EditText editText = editTextWeakReference.get(); if (s.length() <= 0) { editText.setError(editText.getResources().getString(R.string.mandatory_field)); return; } else { editText.setError(null); } editText.removeTextChangedListener(this); Log.d(this.getClass().getSimpleName(), "changed onTextChanged " + String.valueOf(s)); String finalAmount = CurrencyUtils.getInstance().formatAmount(String.valueOf(s)); Log.d(this.getClass().getSimpleName(), "changed onTextChanged " + finalAmount); editText.setText(finalAmount); editText.setSelection(finalAmount.length()); editText.addTextChangedListener(this); }