List of usage examples for android.text Editable clear
public void clear();
From source file:com.robwilliamson.healthyesther.fragment.edit.EditMedicationFragment.java
@Override public void setRow(@Nonnull MedicationTable.Row row) { super.setRow(row); Editable editable = getNameView().getEditableText(); editable.clear(); editable.append(row.getName());/* ww w. j a v a 2s . co m*/ }
From source file:org.mariotaku.twidere.fragment.support.DirectMessagesConversationFragment.java
private void sendDirectMessage() { final Editable text = mEditText.getText(); if (isEmpty(text) || mAccountId <= 0 || mRecipientId <= 0) return;// w w w . j ava2s . co m final String message = text.toString(); if (mValidator.isValidTweet(message)) { mTwitterWrapper.sendDirectMessageAsync(mAccountId, mRecipientId, message); text.clear(); } }
From source file:de.vanita5.twittnuker.fragment.support.DirectMessagesConversationFragment.java
private void sendDirectMessage() { final Editable text = mEditText.getText(); if (isEmpty(text) || mAccountId <= 0 || mRecipientId <= 0) return;/*from w w w .j a va 2 s . c o m*/ final String message = text.toString(); if (mValidator.isValidTweet(message)) { mTwitterWrapper.sendDirectMessageAsync(mAccountId, mRecipientId, message, mImageUri); text.clear(); mImageUri = null; updateAddImageButton(); } }
From source file:org.mariotaku.twidere.fragment.DMConversationFragment.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.send: { final Editable text = mEditText.getText(); if (text == null) return; final String message = text.toString(); if (mValidator.isValidTweet(message)) { final long account_id = mArguments.getLong(INTENT_KEY_ACCOUNT_ID, -1); final long conversation_id = mArguments.getLong(INTENT_KEY_CONVERSATION_ID, -1); final String screen_name = mArguments.getString(INTENT_KEY_SCREEN_NAME); mService.sendDirectMessage(account_id, screen_name, conversation_id, message); text.clear(); }//from w ww.j ava 2 s .com break; } case R.id.screen_name_confirm: { final CharSequence text = mEditScreenName.getText(); if (text == null) return; final String screen_name = text.toString(); mArguments.putString(INTENT_KEY_SCREEN_NAME, screen_name); getLoaderManager().restartLoader(0, mArguments, this); break; } } }
From source file:org.mariotaku.twidere.fragment.DirectMessagesConversationFragment.java
private void send() { final Editable text = mEditText.getText(); if (isEmpty(text)) return;// w w w .j a v a 2 s. c om final String message = text.toString(); if (mValidator.isValidTweet(message)) { final long account_id = mArguments.getLong(INTENT_KEY_ACCOUNT_ID, -1); final long conversation_id = mArguments.getLong(INTENT_KEY_CONVERSATION_ID, -1); final String screen_name = mArguments.getString(INTENT_KEY_SCREEN_NAME); mTwitterWrapper.sendDirectMessage(account_id, screen_name, conversation_id, message); text.clear(); } }
From source file:com.dwdesign.tweetings.fragment.DMConversationFragment.java
private void send() { final Editable text = mEditText.getText(); if (isNullOrEmpty(text)) return;//from w w w . j a va 2s . c o m final String message = text.toString(); if (mValidator.isValidTweet(message)) { final long account_id = mArguments.getLong(INTENT_KEY_ACCOUNT_ID, -1); final long conversation_id = mArguments.getLong(INTENT_KEY_CONVERSATION_ID, -1); final String screen_name = mArguments.getString(INTENT_KEY_SCREEN_NAME); mService.sendDirectMessage(account_id, screen_name, conversation_id, message); text.clear(); } }
From source file:com.forrestguice.suntimeswidget.settings.ColorChooser.java
@Override public void afterTextChanged(Editable editable) { if (isRunning || isRemoving) return;//from www. jav a 2s . c o m isRunning = true; String text = editable.toString(); // should consist of [#][0-9][a-f] for (int j = text.length() - 1; j >= 0; j--) { if (!inputSet.contains(text.charAt(j))) { editable.delete(j, j + 1); } } text = editable.toString(); // should start with a # int i = text.indexOf('#'); if (i != -1) { editable.delete(i, i + 1); } editable.insert(0, "#"); if (editable.length() > 8) // should be no longer than 8 { editable.delete(9, editable.length()); } text = editable.toString(); String toCaps = text.toUpperCase(Locale.US); editable.clear(); editable.append(toCaps); isRunning = false; }
From source file:org.tpmkranz.notifyme.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_checkaccessibility: prefs.setPrevVersion(0);/* w w w .ja va 2s.c o m*/ ((TemporaryStorage) getApplicationContext()).accessGranted(false); finish(); startActivity(getIntent()); return true; case R.id.main_menu_popup: final View view = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.main_menu_popup, null); if (android.os.Build.VERSION.SDK_INT >= 11) view.findViewById(R.id.main_menu_popup_background).setVisibility(View.GONE); ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)) .setChecked(prefs.isBackgroundColorInverted()); view.findViewById(R.id.main_menu_popup_background_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)).toggle(); } }); ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)) .setChecked(prefs.isOrientationFixed()); view.findViewById(R.id.main_menu_popup_orientation_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)).toggle(); } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb(progress, ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), progress, ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), progress))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb(prefs.getSliderBackgroundR(), prefs.getSliderBackgroundG(), prefs.getSliderBackgroundB()))); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .setText(String.valueOf(prefs.getSliderBackgroundR())); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .setText(String.valueOf(prefs.getSliderBackgroundG())); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .setText(String.valueOf(prefs.getSliderBackgroundB())); ((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)).setText( (prefs.getScreenTimeout() == 0L ? "" : String.valueOf(prefs.getScreenTimeout() / 1000L))); ((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().equals("")) return; try { if (Long.parseLong(s.toString()) > 9999L) s.replace(0, s.length(), "9999"); else if (Long.parseLong(s.toString()) < 0L) s.replace(0, s.length(), "0"); } catch (Exception e) { s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .setChecked(prefs.isInterfaceSlider()); ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0) .setEnabled(((CheckBox) v).isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(0).setEnabled(((CheckBox) v).isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(1).setEnabled(((CheckBox) v).isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2) .setVisibility((((CheckBox) v).isChecked() ? View.VISIBLE : View.INVISIBLE)); } }); ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0).setEnabled( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(1)) .getChildAt(i)).getChildAt(0) .setEnabled(((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(1)) .getChildAt(i)).getChildAt(1) .setEnabled(((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2).setVisibility( (((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).isChecked() ? View.VISIBLE : View.INVISIBLE)); view.findViewById(R.id.main_menu_popup_interface_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).toggle(); ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0).setEnabled( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(0) .setEnabled(((CheckBox) view .findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(1) .setEnabled(((CheckBox) view .findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2).setVisibility( (((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked() ? View.VISIBLE : View.INVISIBLE)); } }); new AlertDialog.Builder(this).setView(view) .setPositiveButton(R.string.main_menu_popup_save_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { prefs.setBackgroundColorInverted( ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)) .isChecked()); prefs.setInterfaceSlider( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); prefs.setSliderBackground( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()); prefs.setScreenTimeout( (((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)).getText() .toString().equals("") ? 0L : Long.parseLong(((EditText) view .findViewById(R.id.main_menu_popup_timeout_editor)) .getText().toString()) * 1000L)); prefs.setOrientationFixed( ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)) .isChecked()); } }).setNegativeButton(R.string.main_menu_popup_cancel_button, null).show(); return true; case R.id.main_menu_help: new AlertDialog.Builder(this).setMessage(R.string.main_menu_help_message) .setTitle(R.string.main_menu_help_title) .setPositiveButton(R.string.main_menu_help_ok_button, null).setNegativeButton( R.string.main_menu_help_question_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://forum.xda-developers.com/showthread.php?t=2173226")) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }) .show(); return true; case R.id.main_menu_about: ViewGroup about = (ViewGroup) ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.main_menu_about, null); ((TextView) about.getChildAt(0)).setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(this).setView(about).setTitle(R.string.main_menu_about_title) .setPositiveButton(R.string.main_menu_about_ok_button, null).show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Random r=new Random(); // int uniqueNumber =(r.nextInt(999) + 100); // uniqueId = Integer.toString(uniqueNumber); // ?uniqueId//from w ww . j a va 2 s. c o m UUID uuid = UUID.randomUUID(); uniqueId = uuid.toString(); this.inflater = inflater; rootView = inflater.inflate(R.layout.fragment_car_check_basic_info, container, false); // <editor-fold defaultstate="collapsed" desc="??View?"> tableLayout = (TableLayout) rootView.findViewById(R.id.bi_content_table); contentLayout = (LinearLayout) rootView.findViewById(R.id.brand_input); Button vinButton = (Button) rootView.findViewById(R.id.bi_vin_button); vinButton.setOnClickListener(this); brandOkButton = (Button) rootView.findViewById(R.id.bi_brand_ok_button); brandOkButton.setEnabled(false); brandOkButton.setOnClickListener(this); brandSelectButton = (Button) rootView.findViewById(R.id.bi_brand_select_button); brandSelectButton.setEnabled(false); brandSelectButton.setOnClickListener(this); // ?? sketchPhotoEntities = new ArrayList<PhotoEntity>(); // Button matchButton = (Button) rootView.findViewById(R.id.ct_licencePhotoMatch_button); matchButton.setOnClickListener(this); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; vin_edit = (EditText) rootView.findViewById(R.id.bi_vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps() }); brandEdit = (EditText) rootView.findViewById(R.id.bi_brand_edit); displacementEdit = (EditText) rootView.findViewById(R.id.csi_displacement_edit); transmissionEdit = (EditText) rootView.findViewById(R.id.csi_transmission_edit); runEdit = (EditText) rootView.findViewById(R.id.bi_mileage_edit); // // transmissionSpinner = (Spinner)rootView.findViewById(R.id.csi_transmission_spinner); // transmissionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // @Override // public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // transmissionEdit.setText(adapterView.getSelectedItem().toString()); // } // // @Override // public void onNothingSelected(AdapterView<?> adapterView) { // // } // }); // ?????? ScrollView view = (ScrollView) rootView.findViewById(R.id.root); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); // ????????2? runEdit.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable edt) { String temp = edt.toString(); if (temp.contains(".")) { int posDot = temp.indexOf("."); if (posDot <= 0) return; if (temp.length() - posDot - 1 > 2) { edt.delete(posDot + 3, posDot + 4); } } else { if (temp.length() > 2) { edt.clear(); edt.append(temp.substring(0, 2)); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); licencePhotoMatchEdit = (EditText) rootView.findViewById(R.id.ct_licencePhotoMatch_edit); licencePhotoMatchEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { licencePhotoMatchEdit.setError(null); } @Override public void afterTextChanged(Editable editable) { licencePhotoMatchEdit.setError(null); } }); // ?? carNumberEdit = (EditText) rootView.findViewById(R.id.ci_plateNumber_edit); carNumberEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); // ? portedProcedureRow = (TableRow) rootView.findViewById(R.id.ct_ported_procedure); // ?Spinner setRegLocationSpinner(); setCarColorSpinner(); setFirstLogTimeSpinner(); setManufactureTimeSpinner(); setTransferCountSpinner(); setLastTransferTimeSpinner(); setYearlyCheckAvailableDateSpinner(); setAvailableDateYearSpinner(); setBusinessInsuranceAvailableDateYearSpinner(); setOtherSpinners(); // </editor-fold> mCarSettings = new CarSettings(); // ??xml if (vehicleModel == null) { mProgressDialog = ProgressDialog.show(rootView.getContext(), null, "?..", false, false); Thread thread = new Thread(new Runnable() { @Override public void run() { try { ParseXml(); // jsonData?? if (!jsonData.equals("")) { modifyMode = true; letsEnterModifyMode(); } } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } return rootView; }