How to Get EditText maxLength setting in code

Only limited parameters have their getters, so I don’t think you can read it .

So write length (Say 12) in values folder and use it in xml layout and arrayAdapter .
Now its not hard-coded .

1)Create integer.xml in values *

<?xml version="1.0" encoding="utf-8"?>
    <item type="integer" name="max_length">12</item>

2)In layout

<TextView  android:id="@+id/tv"

3) in ArrayAdapter :

int maxLength = getResources().getInteger(R.integer.max_length);

Leave a Comment