Remove maxLength set from EditText
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.
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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);
add a comment |
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));
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
add a comment |
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);
add a comment |
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);
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);
answered Nov 15 '18 at 10:20
Alesandro GiordanoAlesandro Giordano
318110
318110
add a comment |
add a comment |
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));
add a comment |
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));
add a comment |
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));
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));
edited Nov 15 '18 at 10:38
answered Nov 15 '18 at 10:26
OnixOnix
4578
4578
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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