<i id='iS0s8'><tr id='iS0s8'><dt id='iS0s8'><q id='iS0s8'><span id='iS0s8'><b id='iS0s8'><form id='iS0s8'><ins id='iS0s8'></ins><ul id='iS0s8'></ul><sub id='iS0s8'></sub></form><legend id='iS0s8'></legend><bdo id='iS0s8'><pre id='iS0s8'><center id='iS0s8'></center></pre></bdo></b><th id='iS0s8'></th></span></q></dt></tr></i><div id='iS0s8'><tfoot id='iS0s8'></tfoot><dl id='iS0s8'><fieldset id='iS0s8'></fieldset></dl></div>
  • <small id='iS0s8'></small><noframes id='iS0s8'>

        <bdo id='iS0s8'></bdo><ul id='iS0s8'></ul>
    1. <legend id='iS0s8'><style id='iS0s8'><dir id='iS0s8'><q id='iS0s8'></q></dir></style></legend><tfoot id='iS0s8'></tfoot>

        android EditText maxLength 不起作用

        时间:2023-10-01

      1. <legend id='BbY1I'><style id='BbY1I'><dir id='BbY1I'><q id='BbY1I'></q></dir></style></legend>

          <tbody id='BbY1I'></tbody>

      2. <small id='BbY1I'></small><noframes id='BbY1I'>

                <i id='BbY1I'><tr id='BbY1I'><dt id='BbY1I'><q id='BbY1I'><span id='BbY1I'><b id='BbY1I'><form id='BbY1I'><ins id='BbY1I'></ins><ul id='BbY1I'></ul><sub id='BbY1I'></sub></form><legend id='BbY1I'></legend><bdo id='BbY1I'><pre id='BbY1I'><center id='BbY1I'></center></pre></bdo></b><th id='BbY1I'></th></span></q></dt></tr></i><div id='BbY1I'><tfoot id='BbY1I'></tfoot><dl id='BbY1I'><fieldset id='BbY1I'></fieldset></dl></div>
                  <bdo id='BbY1I'></bdo><ul id='BbY1I'></ul>
                • <tfoot id='BbY1I'></tfoot>
                • 本文介绍了android EditText maxLength 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的xml

                  <EditText
                  android:id="@+id/et_comment"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:inputType="textNoSuggestions|textVisiblePassword"
                  android:hint="Provide comments here..."
                  android:gravity="top"
                  android:maxLength="5"
                  android:textSize="12sp"
                  android:visibility="visible"
                  />
                  

                  使用此代码也不行

                  TextView editEntryView = new TextView(...);
                  InputFilter[] filterArray = new InputFilter[1];
                  filterArray[0] = new InputFilter.LengthFilter(5);
                  editEntryView.setFilters(filterArray);
                  

                  maxLenth 不工作,我不知道为什么,但它不工作.
                  我已经检查了堆栈上的其他答案,但它们也不起作用.
                  请检查是否有任何 EditText 属性冲突或有什么问题?

                  maxLenth is not working, I dont know why, but it isnt.
                  I have checked other answers on the stack but they are also not working.
                  Please check if any of EditText attributes are conflicting or what is the problem?

                  其他开发人员也面临同样的问题
                  查看评论这里 Mansi 和 aat 面临同样的问题
                  而 这里 在评论中,Vincy 和 Riser 也面临同样的问题

                  Same problem is being faced by other developers
                  See comments here same problem is being faced by Mansi and aat
                  And here in comments same problem is being faced by Vincy and Riser

                  问题已解决
                  我正在使用输入过滤器,它覆盖了 xml 中的最大长度,使其无法工作.
                  输入过滤器对我不起作用的原因是我使用了另一个输入过滤器,它覆盖了以前的 maxLength 输入过滤器.
                  把它变成一个单一的输入过滤器为我解决了这个问题.

                  Problem solved
                  I was using input filter which overrides the max length in xml making it not able to work.
                  The reason input filter didn't worked for me was that I was using another input filter which overwrites the previous maxLength input filter.
                  Making it into a single input filter fixed that issue for me.

                  推荐答案

                  相当老的帖子但是,我注意到 XML 是一个实际的 EditText 对象,而您正在将过滤器添加到 TextView 处理它的方式与 EditText 不同.如果您要手动添加 InputFilter 对象,则会覆盖 xml 属性.

                  Fairly old post but, I noticed how the XML is an actual EditText object, while you are adding the filters to a TextView which could handle it differently than EditText. If you are adding an InputFilter object manually, the xml property is overridden.

                  您将 InputFilters 添加到 View 的示例代码似乎是一个 TextView 对象.如果您手动添加过滤器,请确保您拉出正确的视图并将其转换为 EditText - 它现在对我有用.

                  The example code on which you add InputFilters to the View seems to be a TextView object. Make sure you pull the right view and it's being cast to EditText if you go with the manual addition of the filters--it's working for me right now.

                  祝你好运.

                  这篇关于android EditText maxLength 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android - editText 中的默认值 下一篇:获取 EditText 的字符数

                  相关文章

                  最新文章

                  <i id='NuGvp'><tr id='NuGvp'><dt id='NuGvp'><q id='NuGvp'><span id='NuGvp'><b id='NuGvp'><form id='NuGvp'><ins id='NuGvp'></ins><ul id='NuGvp'></ul><sub id='NuGvp'></sub></form><legend id='NuGvp'></legend><bdo id='NuGvp'><pre id='NuGvp'><center id='NuGvp'></center></pre></bdo></b><th id='NuGvp'></th></span></q></dt></tr></i><div id='NuGvp'><tfoot id='NuGvp'></tfoot><dl id='NuGvp'><fieldset id='NuGvp'></fieldset></dl></div>

                  1. <tfoot id='NuGvp'></tfoot>

                    <small id='NuGvp'></small><noframes id='NuGvp'>

                    • <bdo id='NuGvp'></bdo><ul id='NuGvp'></ul>
                  2. <legend id='NuGvp'><style id='NuGvp'><dir id='NuGvp'><q id='NuGvp'></q></dir></style></legend>