Android examples for User Interface:EditText
get EditText Max Length
//package com.java2s; import android.text.InputFilter; import android.widget.EditText; import java.lang.reflect.Field; public class Main { public static int getMaxLength(EditText view) { int length = 0; try {/*from w w w. ja va2s .c o m*/ InputFilter[] inputFilters = view.getFilters(); for (InputFilter filter : inputFilters) { Class<?> c = filter.getClass(); if (c.getName().equals( "android.text.InputFilter$LengthFilter")) { Field[] f = c.getDeclaredFields(); for (Field field : f) { if (field.getName().equals("mMax")) { field.setAccessible(true); length = (Integer) field.get(filter); } } } } } catch (Exception e) { e.printStackTrace(); } return length; } }