Remove maxLength set from EditText










0















As we know, maxLength for EditText is set by:



android:maxLength="19"


or programmatically. My question is that how can I remove this maxLength programmatically if it was set to certain length? I want to set maxLength to the maximum length possible.










share|improve this question






















  • If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

    – Kunu
    Nov 15 '18 at 10:15











  • Try setting it to zero 0 or try find its default value.

    – Sayok Majumder
    Nov 15 '18 at 10:23











  • @Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

    – tm13
    Nov 15 '18 at 10:23















0















As we know, maxLength for EditText is set by:



android:maxLength="19"


or programmatically. My question is that how can I remove this maxLength programmatically if it was set to certain length? I want to set maxLength to the maximum length possible.










share|improve this question






















  • If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

    – Kunu
    Nov 15 '18 at 10:15











  • Try setting it to zero 0 or try find its default value.

    – Sayok Majumder
    Nov 15 '18 at 10:23











  • @Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

    – tm13
    Nov 15 '18 at 10:23













0












0








0








As we know, maxLength for EditText is set by:



android:maxLength="19"


or programmatically. My question is that how can I remove this maxLength programmatically if it was set to certain length? I want to set maxLength to the maximum length possible.










share|improve this question














As we know, maxLength for EditText is set by:



android:maxLength="19"


or programmatically. My question is that how can I remove this maxLength programmatically if it was set to certain length? I want to set maxLength to the maximum length possible.







android android-edittext android-input-filter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 10:12









tm13tm13

5481421




5481421












  • If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

    – Kunu
    Nov 15 '18 at 10:15











  • Try setting it to zero 0 or try find its default value.

    – Sayok Majumder
    Nov 15 '18 at 10:23











  • @Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

    – tm13
    Nov 15 '18 at 10:23

















  • If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

    – Kunu
    Nov 15 '18 at 10:15











  • Try setting it to zero 0 or try find its default value.

    – Sayok Majumder
    Nov 15 '18 at 10:23











  • @Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

    – tm13
    Nov 15 '18 at 10:23
















If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

– Kunu
Nov 15 '18 at 10:15





If you don't want it then remove from the XML file and set it programmatically so that it will be more dynamic.

– Kunu
Nov 15 '18 at 10:15













Try setting it to zero 0 or try find its default value.

– Sayok Majumder
Nov 15 '18 at 10:23





Try setting it to zero 0 or try find its default value.

– Sayok Majumder
Nov 15 '18 at 10:23













@Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

– tm13
Nov 15 '18 at 10:23





@Kunu in my application in some cases I should set it to certain length and remove it in some other conditions. This is why I am asking

– tm13
Nov 15 '18 at 10:23












2 Answers
2






active

oldest

votes


















0














In android there is EditText and sometimes you may want to limit the character input. EditText in XML layout would give you android:maxLength to do this thing but in codes you might wonder why there isn't any setMaxLength function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have to filter them and this would be invoke by setFilters and thus to make our EditText to have a fixed size we shall.



EditText et = new EditText(this);
int maxLength = 3;
InputFilter FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(maxLength);
et.setFilters(FilterArray);





share|improve this answer






























    0














    Just try to set a maxLength property to -1



    android:maxLength="-1"


    or programmatically



    int maxLengthofEditText = -1
    editText.setFilters(new InputFilter new InputFilter.LengthFilter(maxLengthofEditText));





    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317048%2fremove-maxlength-set-from-edittext%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      In android there is EditText and sometimes you may want to limit the character input. EditText in XML layout would give you android:maxLength to do this thing but in codes you might wonder why there isn't any setMaxLength function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have to filter them and this would be invoke by setFilters and thus to make our EditText to have a fixed size we shall.



      EditText et = new EditText(this);
      int maxLength = 3;
      InputFilter FilterArray = new InputFilter[1];
      FilterArray[0] = new InputFilter.LengthFilter(maxLength);
      et.setFilters(FilterArray);





      share|improve this answer



























        0














        In android there is EditText and sometimes you may want to limit the character input. EditText in XML layout would give you android:maxLength to do this thing but in codes you might wonder why there isn't any setMaxLength function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have to filter them and this would be invoke by setFilters and thus to make our EditText to have a fixed size we shall.



        EditText et = new EditText(this);
        int maxLength = 3;
        InputFilter FilterArray = new InputFilter[1];
        FilterArray[0] = new InputFilter.LengthFilter(maxLength);
        et.setFilters(FilterArray);





        share|improve this answer

























          0












          0








          0







          In android there is EditText and sometimes you may want to limit the character input. EditText in XML layout would give you android:maxLength to do this thing but in codes you might wonder why there isn't any setMaxLength function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have to filter them and this would be invoke by setFilters and thus to make our EditText to have a fixed size we shall.



          EditText et = new EditText(this);
          int maxLength = 3;
          InputFilter FilterArray = new InputFilter[1];
          FilterArray[0] = new InputFilter.LengthFilter(maxLength);
          et.setFilters(FilterArray);





          share|improve this answer













          In android there is EditText and sometimes you may want to limit the character input. EditText in XML layout would give you android:maxLength to do this thing but in codes you might wonder why there isn't any setMaxLength function. The reason behind this is that when you want to restrict the EditText to accept certain value, you have to filter them and this would be invoke by setFilters and thus to make our EditText to have a fixed size we shall.



          EditText et = new EditText(this);
          int maxLength = 3;
          InputFilter FilterArray = new InputFilter[1];
          FilterArray[0] = new InputFilter.LengthFilter(maxLength);
          et.setFilters(FilterArray);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 10:20









          Alesandro GiordanoAlesandro Giordano

          318110




          318110























              0














              Just try to set a maxLength property to -1



              android:maxLength="-1"


              or programmatically



              int maxLengthofEditText = -1
              editText.setFilters(new InputFilter new InputFilter.LengthFilter(maxLengthofEditText));





              share|improve this answer





























                0














                Just try to set a maxLength property to -1



                android:maxLength="-1"


                or programmatically



                int maxLengthofEditText = -1
                editText.setFilters(new InputFilter new InputFilter.LengthFilter(maxLengthofEditText));





                share|improve this answer



























                  0












                  0








                  0







                  Just try to set a maxLength property to -1



                  android:maxLength="-1"


                  or programmatically



                  int maxLengthofEditText = -1
                  editText.setFilters(new InputFilter new InputFilter.LengthFilter(maxLengthofEditText));





                  share|improve this answer















                  Just try to set a maxLength property to -1



                  android:maxLength="-1"


                  or programmatically



                  int maxLengthofEditText = -1
                  editText.setFilters(new InputFilter new InputFilter.LengthFilter(maxLengthofEditText));






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 15 '18 at 10:38

























                  answered Nov 15 '18 at 10:26









                  OnixOnix

                  4578




                  4578



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317048%2fremove-maxlength-set-from-edittext%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      What does pagestruct do in Eviews?

                      Dutch intervention in Lombok and Karangasem

                      Channel Islands