replace All Text from Editable - Android android.text

Android examples for android.text:Editable

Description

replace All Text from Editable

Demo Code


//package com.java2s;

import android.text.Editable;
import android.text.InputFilter;

public class Main {
    public static void replaceAllText(Editable editable,
            CharSequence newString) {
        InputFilter[] filters = editable.getFilters();
        editable.setFilters(new InputFilter[] {});
        // We need to remove filters so we can add text with spaces.
        editable.replace(0, editable.length(), newString);
        editable.setFilters(filters);/*  www.  j a  v a2s  .com*/
    }
}

Related Tutorials