Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Arrays;

import android.text.InputFilter;
import android.widget.TextView;

public class Main {
    public static void addLengthFilter(TextView tv, int length) {
        tv.setFilters(createLengthFilter(tv.getFilters(), length));
    }

    public static InputFilter[] createLengthFilter(InputFilter[] filter, int length) {
        InputFilter[] f = Arrays.copyOf(filter, filter.length + 1);
        f[f.length - 1] = new InputFilter.LengthFilter(length);
        return f;
    }
}