List of usage examples for android.text Editable toString
public String toString();
From source file:Main.java
public static void convertToLowercase(Editable s) { String lowerCase = s.toString().toLowerCase(); if (!lowerCase.equals(s.toString())) { s.replace(0, s.length(), lowerCase); }/*w w w . ja v a 2s . c o m*/ }
From source file:Main.java
public static double parseDouble(Editable text) { return parseDouble(text.toString()); }
From source file:Main.java
public static boolean isEmpty(Editable value) { return value == null || isEmpty(value.toString()); }
From source file:Main.java
public static final void setEditTextSelectionToEnd(EditText editText) { Editable editable = editText.getEditableText(); Selection.setSelection((Spannable) editable, editable.toString().length()); }
From source file:Main.java
public static String getEditTextValue(EditText editText) { String result = ""; if (editText == null) return result; Editable editable = editText.getText(); if (editable == null) return result; result = editable.toString(); if (result == null) result = ""; return result.trim(); }
From source file:cn.foxnickel.listentome.view.ViewUtil.java
/** * /*w ww . ja v a 2s . com*/ */ public static final void setEditTextSelectionToEnd(EditText editText) { Editable editable = editText.getEditableText(); Selection.setSelection((Spannable) editable, editable.toString().length()); }
From source file:me.panpf.tool4a.util.InputMethodUtils.java
/** * ?/* w ww. j a v a 2s . c o m*/ */ @SuppressWarnings("WeakerAccess") public static void moveCursorToEnd(EditText editText) { Editable editable = editText.getEditableText(); Selection.setSelection(editable, editable.toString().length()); }
From source file:Main.java
/** * Formats the text while the user types for Expiration Date * @param et The edit text being worked on * @param textWatcher Text watcher to both remove and add back on. (Pass 'this' from class) * @param <T> T extends EditText//from w ww .j ava 2 s . c o m */ public static <T extends EditText> void formatExpirationDateWhileTyping(T et, TextWatcher textWatcher) { if (et == null) { return; } if (textWatcher == null) { return; } Editable s = et.getText(); if (s == null) { return; } if (s.length() > 0) { String input = s.toString(); input = input.replace("/", ""); input = input.replace(" / ", ""); if (input.length() <= 2) { } else if (input.length() >= 3 && input.length() <= 7) { String sub1 = input.substring(0, 2); String sub2 = input.substring(2); String toSet = sub1 + "/" + sub2; et.removeTextChangedListener(textWatcher); et.setText(toSet); et.setSelection(toSet.length()); et.addTextChangedListener(textWatcher); } } }
From source file:cc.softwarefactory.lokki.android.utilities.DialogUtils.java
public static void addPlace(final Context context, final LatLng latLng, final int radius) { final EditText input = new EditText(context); // Set an EditText view to get user input input.setSingleLine(true);// w w w . j a v a 2s . c o m final AlertDialog addPlaceDialog = new AlertDialog.Builder(context) .setTitle(context.getResources().getString(R.string.write_place_name)).setView(input) .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create(); addPlaceDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ((FragmentActivity) context).findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE); // todo maybe re enabled this... it will however also fire on empty input } }); addPlaceDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { addPlaceDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Editable value = input.getText(); if (value == null || value.toString().isEmpty()) { input.setError(context.getResources().getString(R.string.required)); return; } try { ServerApi.addPlace(context, value.toString(), latLng, radius); } catch (JSONException e) { e.printStackTrace(); } addPlaceDialog.dismiss(); } }); } }); addPlaceDialog.show(); }
From source file:cc.softwarefactory.lokki.android.utilities.DialogUtils.java
public static void addContact(final Context context) { final EditText input = new EditText(context); // Set an EditText view to get user input input.setSingleLine(true);// w w w . j a v a 2s. c o m input.setHint(R.string.contact_email_address); input.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS); final AlertDialog addContactDialog = new AlertDialog.Builder(context) .setTitle(context.getResources().getString(R.string.add_contact)).setView(input) .setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).create(); addContactDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { addContactDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Editable value = input.getText(); if (value == null || value.toString().isEmpty()) { input.setError(context.getResources().getString(R.string.required)); return; } String email = value.toString(); try { ServerApi.allowPeople(context, email); Toast.makeText(context, R.string.contact_added, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } addContactDialog.dismiss(); } }); } }); addContactDialog.show(); }