Android examples for User Interface:TextView
Set max text length for TextView
//package com.java2s; import android.text.InputFilter; import android.widget.TextView; public class Main { /**/*from w ww. j a v a2 s . c om*/ * Set max text length for textview ****/ public static void setMaxLength(TextView textView, int maxLength) { if (textView == null) { throw new NullPointerException("TextView cannot be null"); } InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(maxLength); textView.setFilters(fArray); } }