views:

248

answers:

1

friends,

i want to set MaxLenght of TextView Through programming i cannot see Set function related to MaxLenght can any one guide me how to achieve this? i dont want hard code in layout.

any help would be appriciated.

+2  A: 

Should be something like that. but never used it for textview, only edittext :

TextView tv = new TextView(this);
int maxLength = 10;
InputFilter[] fArray = new InputFilter[1];
fArray[0] = new InputFilter.LengthFilter(maxLength);
tv.setFilters(fArray)
Sephy