Android Editable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Editable class.

This code example shows how to use the following methods: append
		public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
			 
			if("li".equals(tag)){
				 
				if(opening){
					output.append("  ");
					output.append(BULLET);
					output.append("  ");
				}else{ 
					output.append("\n");
				} 
				 
				 
			} 
		} 
		 
    } 
	 
	 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: removeSpan, setSpan, getSpanStart, length
        int length = output.length();
        output.setSpan(span, length, length, SPAN_MARK_MARK);
    } 
 
    private static void endSpan(Class<?> type, Editable output) {
        int length = output.length();
        Object span = getLast(output, type);
        int start = output.getSpanStart(span);
        output.removeSpan(span);
        if (start != length)
            output.setSpan(span, start, length, SPAN_EXCLUSIVE_EXCLUSIVE);
    } 
 
    /** 
     * Encode HTML 
     * 
     * @param html 
     * @return html 
     */ 
    public static CharSequence encode(final String html) {
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: replace, equals, length
	// IMPLEMENTATION 
	////////////////////////////////////////////////////////////////////////////////////// 
 
	@Override 
	public void afterTextChanged(Editable s) {
		String filtered = mMaskFormatter.valueToString(s);
		Log.t("original: %s - filtered: %s", s, filtered);
 
		if (!TextUtils.equals(s, filtered)) {
			s.replace(0, s.length(), filtered);
		} 
	} 
 
	@Override 
	public void beforeTextChanged(CharSequence s, int start, int count, int after) {
	} 
 
	@Override 
	public void onTextChanged(CharSequence s, int start, int before, int count) {
	} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: append, clear
		public void afterTextChanged(final Editable s) {
			// workaround for German keyboards 
			final String original = s.toString();
			final String replaced = original.replace(',', '.');
			if (!replaced.equals(original)) {
				s.clear();
				s.append(replaced);
			} 
 
			updateSpans(s);
		} 
 
		public void beforeTextChanged(final CharSequence s, final int start,
				final int count, final int after) {
		} 
 
		public void onTextChanged(final CharSequence s, final int start,
				final int before, final int count) {
			updateAppearance(); 
			if (listener != null)
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: insert
  @Override 
  public boolean onKey(View v, int keyCode, KeyEvent event) {
    Editable text=editor.getText();
 
    if (keyCode == KeyEvent.KEYCODE_TAB) {
      text.insert(editor.getSelectionStart(), "\t");
    } 
    else if (event.isCtrlPressed()) {
      int rawStart=editor.getSelectionStart();
      int rawEnd=editor.getSelectionEnd();
      int selStart=(rawStart>rawEnd ? rawEnd : rawStart);
      int selEnd=(rawStart>rawEnd ? rawStart : rawEnd);
       
      switch (keyCode) {
        case KeyEvent.KEYCODE_T:
          Toast.makeText(this,
                         TextUtils.substring(text, selStart, selEnd),
                         Toast.LENGTH_LONG).show();
 
          return(true); 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toString
  public static boolean isEmpty(CharSequence value) {
    return value == null || isEmpty(value.toString());
  } 
 
  public static boolean isEmpty(Editable value) {
    return value == null || isEmpty(value.toString());
  } 
 
  public static void showAlertDialog(Context context, String title, String message) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIcon(android.R.drawable.ic_dialog_alert);
    dialog.setPositiveButton(android.R.string.ok, null);
    dialog.show();
  } 
 
  // XXX-S The consumers of these are way way down in the audio/microphone code. 
  // Is it possible to refactor them so that they bubble up their errors in a way 
  // that's a little cleaner than reaching back up from all the way down there? 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: append, insert, setSpan, length, toString
            handleListTag(output);
    } 
 
    private void handleListTag(Editable output) {
        if (mListParents.lastElement().equals("ul")) {
            output.append("\n");
            String[] split = output.toString().split("\n");
 
            int lastIndex = split.length - 1;
            int start = output.length() - split[lastIndex].length() - 1;
            output.setSpan(new BulletSpan(15 * mListParents.size()), start,
                    output.length(), 0);
        } else if (mListParents.lastElement().equals("ol")) {
            mListItemCount++;
 
            output.append("\n");
            String[] split = output.toString().split("\n");
 
            int lastIndex = split.length - 1;
            int start = output.length() - split[lastIndex].length() - 1;

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: delete, getSelectionEnd, getSelectionStart, getOffsetAfter
                             KeyEvent event) {
        int selStart, selEnd;
        boolean result = true;
 
        { 
            int a = Selection.getSelectionStart(content);
            int b = Selection.getSelectionEnd(content);
 
            selStart = Math.min(a, b);
            selEnd = Math.max(a, b);
        } 
 
        if (selStart != selEnd) {
            content.delete(selStart, selEnd);
        } else { 
            int to = TextUtils.getOffsetAfter(content, selEnd);
 
            if (to != selEnd) {
                content.delete(Math.min(to, selEnd), Math.max(to, selEnd));
            } 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: removeSpan, setSpan, getSpanFlags
 
        return false; // no super to call through to 
    } 
 
    private void press(Editable content, Object what) {
        int state = content.getSpanFlags(what);
 
        if (state == PRESSED)
            ; // repeat before use 
        else if (state == RELEASED)
            content.setSpan(what, 0, 0, LOCKED);
        else if (state == USED)
            ; // repeat after use 
        else if (state == LOCKED)
            content.removeSpan(what);
        else 
            content.setSpan(what, 0, 0, PRESSED);
    } 
 
    /** 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: length
            mDeviceNameUpdated = false;
            mOkButton.setEnabled(false);
        } else { 
            mDeviceNameEdited = true;
            if (mOkButton != null) {
                mOkButton.setEnabled(s.length() != 0 && !(s.toString().trim().isEmpty()));
            } 
        } 
    } 
 
    /* Not used */ 
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    } 
 
    /* Not used */ 
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Editable Questions & Answers:

Other Android Editable Examples

62:				
63:				@Override
64:				public void afterTextChanged(Editable arg0) {
65:					// TODO Auto-generated method stub							
66:				}

Read More

See Code Examples for Android Editable Methods: