How to Get EditText maxLength setting in code

后端 未结 7 1187
鱼传尺愫
鱼传尺愫 2020-12-01 12:34

I would like to see the maxLength of an EditText at run time to be able to make a text display decision.
Is that possible?

Here is a de

7条回答
  •  半阙折子戏
    2020-12-01 13:06

    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 *

    
    
        12
    
    

    2)In layout

    
    

    3) in ArrayAdapter :

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

提交回复
热议问题