reset EditText - Android User Interface

Android examples for User Interface:EditText

Description

reset EditText

Demo Code


import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.CharacterStyle;
import android.widget.EditText;
import java.util.ArrayList;

public class Main{
    public static void reset(EditText editText) {
        Object[] spans = editText.getText().getSpans(0, editText.length(),
                Object.class);
        for (Object span : spans) {
            if (span instanceof CharacterStyle) {
                editText.getText().removeSpan(span);
            }/*from  w ww.  jav a2  s  .  c om*/
        }
    }
}

Related Tutorials