How to Get EditText maxLength setting in code

后端 未结 7 1170
鱼传尺愫
鱼传尺愫 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:11

    Kind of complicated, but I don't know of any other approach. I hope it works (not tested):

    XmlResourceParser parser = getResources().getLayout(R.layout.theLayout);
    String namespace = "http://schemas.android.com/apk/res/android";
    int maxLength = parser.getAttributeIntValue(namespace, "maxLength", 12);
    
    0 讨论(0)
提交回复
热议问题