{"id":1614,"date":"2012-06-04T05:27:52","date_gmt":"2012-06-04T05:27:52","guid":{"rendered":"http:\/\/www.mobisoftinfotech.com\/blog\/?p=1614"},"modified":"2024-11-18T16:06:55","modified_gmt":"2024-11-18T10:36:55","slug":"android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","status":"publish","type":"post","link":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","title":{"rendered":"Android EditText : setFilters Example : Numeric Text field Patterns and Length Restriction."},"content":{"rendered":"<p>Sometimes requirement comes in a way when one needs to restrict characters to be entered in Edit Text. Scenario can be \u201cusername should be greater than 6 characters\u201d, \u201caccepts only decimal number with 2 digits after fraction\u201d, etc.<\/p>\n<p>In this regard, EditText&#8217; setFilters works at its best. EditText&#8217;s setFilters method can be used while playing with length of characters to be entered or entering data in particular pattern in EditText. To freeze such requirement with quickest solution, I have written Custom EditText Locker. One can use this class file along with two lines of code in Main activity to suffice the purpose. If needed more patterns of accepting data in EditText can be added to same class file to make it more generic. For example to make custom locker I have added two EditTexts one which accepts any character with limit of 4 and another EditText which accepts decimal number with only two digits after fraction.<\/p>\n<h2><b>Code for EditTextLocker.java<\/b><\/h2>\n<pre style=\"color: #000000; background: #ffffff;\"><span style=\"color: #800000; font-weight: bold;\">package<\/span><span style=\"color: #004a43;\"> com<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">edittextlocker<\/span><span style=\"color: #800080;\">;<\/span>\n\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">text<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">Editable<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">text<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">InputFilter<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">text<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">Spanned<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">text<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">TextWatcher<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">view<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">KeyEvent<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">view<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">View<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">view<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">View<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">OnKeyListener<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">widget<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">EditText<\/span><span style=\"color: #800080;\">;<\/span>\n\n<span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #800000; font-weight: bold;\">class<\/span> EditTextLocker <span style=\"color: #800080;\">{<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> EditText editText<span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> <span style=\"color: #bb7977;\">int<\/span> charactersLimit<span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> <span style=\"color: #bb7977;\">int<\/span> fractionLimit<span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> EditTextLocker<span style=\"color: #808030;\">(<\/span>EditText editText<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800000; font-weight: bold;\">this<\/span><span style=\"color: #808030;\">.<\/span>editText <span style=\"color: #808030;\">=<\/span> editText<span style=\"color: #800080;\">;<\/span>\n\n        editText<span style=\"color: #808030;\">.<\/span>setOnKeyListener<span style=\"color: #808030;\">(<\/span>editTextOnKeyListener<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n    <span style=\"color: #800080;\">}<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> OnKeyListener editTextOnKeyListener <span style=\"color: #808030;\">=<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> OnKeyListener<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">boolean<\/span> onKey<span style=\"color: #808030;\">(<\/span>View v<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> keyCode<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977; font-weight: bold;\">KeyEvent<\/span> event<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n            <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span>keyCode <span style=\"color: #808030;\">=<\/span><span style=\"color: #808030;\">=<\/span> <span style=\"color: #bb7977; font-weight: bold;\">KeyEvent<\/span><span style=\"color: #808030;\">.<\/span>KEYCODE_DEL<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n                startStopEditing<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">false<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n            <span style=\"color: #800080;\">}<\/span>\n\n            <span style=\"color: #800000; font-weight: bold;\">return<\/span> <span style=\"color: #800000; font-weight: bold;\">false<\/span><span style=\"color: #800080;\">;<\/span>\n        <span style=\"color: #800080;\">}<\/span>\n    <span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> TextWatcher editTextWatcherForCharacterLimits <span style=\"color: #808030;\">=<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> TextWatcher<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> onTextChanged<span style=\"color: #808030;\">(<\/span>CharSequence s<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> before<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> count<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n            <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">!<\/span>editText<span style=\"color: #808030;\">.<\/span>getText<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>toString<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>equalsIgnoreCase<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">\"\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n                <span style=\"color: #bb7977;\">int<\/span> editTextLength <span style=\"color: #808030;\">=<\/span> editText<span style=\"color: #808030;\">.<\/span>getText<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>toString<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>trim<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>length<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n                <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span>editTextLength <span style=\"color: #808030;\">&gt;<\/span><span style=\"color: #808030;\">=<\/span> charactersLimit<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n                    startStopEditing<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">true<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n                <span style=\"color: #800080;\">}<\/span>\n\n            <span style=\"color: #800080;\">}<\/span>\n        <span style=\"color: #800080;\">}<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> beforeTextChanged<span style=\"color: #808030;\">(<\/span>CharSequence s<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> count<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> after<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800080;\">}<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> afterTextChanged<span style=\"color: #808030;\">(<\/span>Editable s<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800080;\">}<\/span>\n    <span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> TextWatcher editTextWatcherForFractionLimit <span style=\"color: #808030;\">=<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> TextWatcher<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> onTextChanged<span style=\"color: #808030;\">(<\/span>CharSequence s<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> before<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> count<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n            <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">!<\/span>editText<span style=\"color: #808030;\">.<\/span>getText<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>toString<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>equalsIgnoreCase<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">\"\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n                <span style=\"color: #bb7977; font-weight: bold;\">String<\/span> editTextString <span style=\"color: #808030;\">=<\/span> editText<span style=\"color: #808030;\">.<\/span>getText<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>toString<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>trim<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n                <span style=\"color: #bb7977;\">int<\/span> decimalIndexOf <span style=\"color: #808030;\">=<\/span> editTextString<span style=\"color: #808030;\">.<\/span>indexOf<span style=\"color: #808030;\">(<\/span><span style=\"color: #0000e6;\">\".\"<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n                <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span>decimalIndexOf <span style=\"color: #808030;\">&gt;<\/span><span style=\"color: #808030;\">=<\/span> <span style=\"color: #008c00;\">0<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n                    <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span>editTextString<span style=\"color: #808030;\">.<\/span>substring<span style=\"color: #808030;\">(<\/span>decimalIndexOf<span style=\"color: #808030;\">)<\/span><span style=\"color: #808030;\">.<\/span>length<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #808030;\">&gt;<\/span> fractionLimit<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n                        startStopEditing<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">true<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n                    <span style=\"color: #800080;\">}<\/span>\n                <span style=\"color: #800080;\">}<\/span>\n\n            <span style=\"color: #800080;\">}<\/span>\n\n        <span style=\"color: #800080;\">}<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> beforeTextChanged<span style=\"color: #808030;\">(<\/span>CharSequence s<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> count<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> after<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800080;\">}<\/span>\n\n        <span style=\"color: #808030;\">@<\/span>Override\n        <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> afterTextChanged<span style=\"color: #808030;\">(<\/span>Editable s<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800080;\">}<\/span>\n    <span style=\"color: #800080;\">}<\/span><span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> limitCharacters<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">final<\/span> <span style=\"color: #bb7977;\">int<\/span> limit<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800000; font-weight: bold;\">this<\/span><span style=\"color: #808030;\">.<\/span>charactersLimit <span style=\"color: #808030;\">=<\/span> limit<span style=\"color: #800080;\">;<\/span>\n        editText<span style=\"color: #808030;\">.<\/span>addTextChangedListener<span style=\"color: #808030;\">(<\/span>editTextWatcherForCharacterLimits<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n    <span style=\"color: #800080;\">}<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> limitFractionDigitsinDecimal<span style=\"color: #808030;\">(<\/span><span style=\"color: #bb7977;\">int<\/span> fractionLimit<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800000; font-weight: bold;\">this<\/span><span style=\"color: #808030;\">.<\/span>fractionLimit <span style=\"color: #808030;\">=<\/span> fractionLimit<span style=\"color: #800080;\">;<\/span>\n        editText<span style=\"color: #808030;\">.<\/span>addTextChangedListener<span style=\"color: #808030;\">(<\/span>editTextWatcherForFractionLimit<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n    <span style=\"color: #800080;\">}<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> unlockEditText<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        startStopEditing<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">false<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n    <span style=\"color: #800080;\">}<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> startStopEditing<span style=\"color: #808030;\">(<\/span><span style=\"color: #bb7977;\">boolean<\/span> isLock<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800000; font-weight: bold;\">if<\/span> <span style=\"color: #808030;\">(<\/span>isLock<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n            editText<span style=\"color: #808030;\">.<\/span>setFilters<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">new<\/span> InputFilter<span style=\"color: #808030;\">[<\/span><span style=\"color: #808030;\">]<\/span> <span style=\"color: #800080;\">{<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> InputFilter<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n                <span style=\"color: #808030;\">@<\/span>Override\n                <span style=\"color: #800000; font-weight: bold;\">public<\/span> CharSequence filter<span style=\"color: #808030;\">(<\/span>CharSequence source<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> end<span style=\"color: #808030;\">,<\/span> Spanned dest<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> dstart<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> dend<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n                    <span style=\"color: #800000; font-weight: bold;\">return<\/span> source<span style=\"color: #808030;\">.<\/span>length<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #808030;\">&lt;<\/span> <span style=\"color: #008c00;\">1<\/span> <span style=\"color: #808030;\">?<\/span> dest<span style=\"color: #808030;\">.<\/span>subSequence<span style=\"color: #808030;\">(<\/span>dstart<span style=\"color: #808030;\">,<\/span> dend<span style=\"color: #808030;\">)<\/span> <span style=\"color: #808030;\">:<\/span> <span style=\"color: #0000e6;\">\"\"<\/span><span style=\"color: #800080;\">;<\/span>\n                <span style=\"color: #800080;\">}<\/span>\n            <span style=\"color: #800080;\">}<\/span> <span style=\"color: #800080;\">}<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n        <span style=\"color: #800080;\">}<\/span> <span style=\"color: #800000; font-weight: bold;\">else<\/span> <span style=\"color: #800080;\">{<\/span>\n\n            editText<span style=\"color: #808030;\">.<\/span>setFilters<span style=\"color: #808030;\">(<\/span><span style=\"color: #800000; font-weight: bold;\">new<\/span> InputFilter<span style=\"color: #808030;\">[<\/span><span style=\"color: #808030;\">]<\/span> <span style=\"color: #800080;\">{<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> InputFilter<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n                <span style=\"color: #808030;\">@<\/span>Override\n                <span style=\"color: #800000; font-weight: bold;\">public<\/span> CharSequence filter<span style=\"color: #808030;\">(<\/span>CharSequence source<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> start<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> end<span style=\"color: #808030;\">,<\/span> Spanned dest<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> dstart<span style=\"color: #808030;\">,<\/span> <span style=\"color: #bb7977;\">int<\/span> dend<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n                    <span style=\"color: #800000; font-weight: bold;\">return<\/span> <span style=\"color: #800000; font-weight: bold;\">null<\/span><span style=\"color: #800080;\">;<\/span>\n                <span style=\"color: #800080;\">}<\/span>\n            <span style=\"color: #800080;\">}<\/span> <span style=\"color: #800080;\">}<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n        <span style=\"color: #800080;\">}<\/span>\n    <span style=\"color: #800080;\">}<\/span>\n<span style=\"color: #800080;\">}<\/span><\/pre>\n<h2><b>Code for Main.java<\/b><\/h2>\n<pre style=\"color: #000000; background: #ffffff;\"><span style=\"color: #800000; font-weight: bold;\">package<\/span><span style=\"color: #004a43;\"> com<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">edittextlocker<\/span><span style=\"color: #800080;\">;<\/span>\n\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">app<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">Activity<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">os<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">Bundle<\/span><span style=\"color: #800080;\">;<\/span>\n<span style=\"color: #800000; font-weight: bold;\">import<\/span><span style=\"color: #004a43;\"> android<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">widget<\/span><span style=\"color: #808030;\">.<\/span><span style=\"color: #004a43;\">EditText<\/span><span style=\"color: #800080;\">;<\/span>\n\n<span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #800000; font-weight: bold;\">class<\/span> Main <span style=\"color: #800000; font-weight: bold;\">extends<\/span> Activity <span style=\"color: #800080;\">{<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> EditText editText<span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800000; font-weight: bold;\">private<\/span> EditText decimalEditText<span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #808030;\">@<\/span>Override\n    <span style=\"color: #800000; font-weight: bold;\">public<\/span> <span style=\"color: #bb7977;\">void<\/span> onCreate<span style=\"color: #808030;\">(<\/span>Bundle savedInstanceState<span style=\"color: #808030;\">)<\/span> <span style=\"color: #800080;\">{<\/span>\n\n        <span style=\"color: #800000; font-weight: bold;\">super<\/span><span style=\"color: #808030;\">.<\/span>onCreate<span style=\"color: #808030;\">(<\/span>savedInstanceState<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n        setContentView<span style=\"color: #808030;\">(<\/span>R<span style=\"color: #808030;\">.<\/span>layout<span style=\"color: #808030;\">.<\/span>main<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n        editText <span style=\"color: #808030;\">=<\/span> <span style=\"color: #808030;\">(<\/span>EditText<span style=\"color: #808030;\">)<\/span> findViewById<span style=\"color: #808030;\">(<\/span>R<span style=\"color: #808030;\">.<\/span>id<span style=\"color: #808030;\">.<\/span>edittext<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n        decimalEditText <span style=\"color: #808030;\">=<\/span> <span style=\"color: #808030;\">(<\/span>EditText<span style=\"color: #808030;\">)<\/span> findViewById<span style=\"color: #808030;\">(<\/span>R<span style=\"color: #808030;\">.<\/span>id<span style=\"color: #808030;\">.<\/span>decimal_edittext<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n        EditTextLocker editTextLocker <span style=\"color: #808030;\">=<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> EditTextLocker<span style=\"color: #808030;\">(<\/span>editText<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n        editTextLocker<span style=\"color: #808030;\">.<\/span>limitCharacters<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">4<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n        EditTextLocker decimalEditTextLocker <span style=\"color: #808030;\">=<\/span> <span style=\"color: #800000; font-weight: bold;\">new<\/span> EditTextLocker<span style=\"color: #808030;\">(<\/span>decimalEditText<span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n        decimalEditTextLocker<span style=\"color: #808030;\">.<\/span>limitFractionDigitsinDecimal<span style=\"color: #808030;\">(<\/span><span style=\"color: #008c00;\">2<\/span><span style=\"color: #808030;\">)<\/span><span style=\"color: #800080;\">;<\/span>\n\n    <span style=\"color: #800080;\">}<\/span>\n\n<span style=\"color: #800080;\">}<\/span><\/pre>\n<h2><b>Code for main.xml<\/b><\/h2>\n<pre style=\"color: #000000; background: #ffffff;\"><span style=\"color: #004a43;\">&lt;?<\/span><span style=\"color: #800000; font-weight: bold;\">xml<\/span><span style=\"color: #074726;\">version<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #7d0045;\">1.0<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #074726;\">encoding<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">utf-8<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #004a43;\">?&gt;<\/span>\n<span style=\"color: #a65700;\">&lt;<\/span><span style=\"color: #5f5035;\">LinearLayout<\/span> <span style=\"color: #666616;\">xmlns<\/span><span style=\"color: #800080;\">:<\/span><span style=\"color: #074726;\">android<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #666616;\">http<\/span><span style=\"color: #800080;\">:<\/span><span style=\"color: #800000; font-weight: bold;\">\/\/<\/span><span style=\"color: #5555dd;\">schemas.android.com<\/span><span style=\"color: #40015a;\">\/apk\/res\/android<\/span><span style=\"color: #0000e6;\">\"<\/span>\n    <span style=\"color: #274796;\">android:layout_width<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">fill_parent<\/span><span style=\"color: #0000e6;\">\"<\/span>\n    <span style=\"color: #274796;\">android:layout_height<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">fill_parent<\/span><span style=\"color: #0000e6;\">\"<\/span>\n    <span style=\"color: #274796;\">android:orientation<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">vertical<\/span><span style=\"color: #0000e6;\">\"<\/span> <span style=\"color: #a65700;\">&gt;<\/span>\n\n    <span style=\"color: #a65700;\">&lt;<\/span><span style=\"color: #5f5035;\">EditText<\/span>\n        <span style=\"color: #274796;\">android:id<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">@+id\/edittext<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:layout_width<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">fill_parent<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:layout_height<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">wrap_content<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:hint<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">Accepts any 4 characters<\/span><span style=\"color: #0000e6;\">\"<\/span> <span style=\"color: #a65700;\">&gt;<\/span>\n    <span style=\"color: #a65700;\">&lt;\/<\/span><span style=\"color: #5f5035;\">EditText<\/span><span style=\"color: #a65700;\">&gt;<\/span>\n\n    <span style=\"color: #a65700;\">&lt;<\/span><span style=\"color: #5f5035;\">EditText<\/span>\n        <span style=\"color: #274796;\">android:id<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">@+id\/decimal_edittext<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:layout_width<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">wrap_content<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:layout_height<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">wrap_content<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:inputType<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">numberDecimal<\/span><span style=\"color: #0000e6;\">\"<\/span>\n        <span style=\"color: #274796;\">android:hint<\/span><span style=\"color: #808030;\">=<\/span><span style=\"color: #0000e6;\">\"<\/span><span style=\"color: #0000e6;\">Accepts decimal with 2 fraction digits<\/span><span style=\"color: #0000e6;\">\"<\/span> <span style=\"color: #a65700;\">\/&gt;<\/span>\n\n<span style=\"color: #a65700;\">&lt;\/<\/span><span style=\"color: #5f5035;\">LinearLayout<\/span><span style=\"color: #a65700;\">&gt;<\/span><\/pre>\n<p>You can download the complete <a href=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/06\/EdittextLock1.zip\">source code for the project from here<\/a><\/p>\n<div style=\"display: none;\">what is the best way to support my manwhy your ex girlfriend what u as your frind she have a boy friend <a href=\"https:\/\/www.keeplexingtonbeautiful.com\/\">We Just Spoke After Breaking Up What Next<\/a> how do i win my boyfriend backmy ex girlfriend tells everyone hello but me<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes requirement comes in a way when one needs to restrict characters to be entered in Edit Text. Scenario can be \u201cusername should be greater than 6 characters\u201d, \u201caccepts only decimal number with 2 digits after fraction\u201d, etc. In this regard, EditText&#8217; setFilters works at its best. EditText&#8217;s setFilters method can be used while playing [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"","footnotes":""},"categories":[4],"tags":[459,201,204,203],"class_list":["post-1614","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-edittext","tag-edittext-setfilters","tag-numeric-only-edittext"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android EditText : setFilters Example : Numeric Text<\/title>\n<meta name=\"description\" content=\"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android EditText : setFilters Example : Numeric Text\" \/>\n<meta property=\"og:description\" content=\"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\" \/>\n<meta property=\"og:site_name\" content=\"Mobisoft Infotech\" \/>\n<meta property=\"article:published_time\" content=\"2012-06-04T05:27:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-18T10:36:55+00:00\" \/>\n<meta name=\"author\" content=\"Pallavi Daga\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Daga\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\"},\"author\":{\"name\":\"Pallavi Daga\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3\"},\"headline\":\"Android EditText : setFilters Example : Numeric Text field Patterns and Length Restriction.\",\"datePublished\":\"2012-06-04T05:27:52+00:00\",\"dateModified\":\"2024-11-18T10:36:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\"},\"wordCount\":233,\"commentCount\":0,\"keywords\":[\"Android\",\"EditText\",\"EditText setFilters\",\"Numeric only EditText\"],\"articleSection\":[\"Android\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\",\"name\":\"Android EditText : setFilters Example : Numeric Text\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\"},\"datePublished\":\"2012-06-04T05:27:52+00:00\",\"dateModified\":\"2024-11-18T10:36:55+00:00\",\"author\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3\"},\"description\":\"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control\",\"breadcrumb\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobisoftinfotech.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android EditText : setFilters Example : Numeric Text field Patterns and Length Restriction.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/\",\"name\":\"Mobisoft Infotech\",\"description\":\"Discover Mobility\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3\",\"name\":\"Pallavi Daga\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g\",\"caption\":\"Pallavi Daga\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android EditText : setFilters Example : Numeric Text","description":"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","og_locale":"en_US","og_type":"article","og_title":"Android EditText : setFilters Example : Numeric Text","og_description":"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control","og_url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","og_site_name":"Mobisoft Infotech","article_published_time":"2012-06-04T05:27:52+00:00","article_modified_time":"2024-11-18T10:36:55+00:00","author":"Pallavi Daga","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pallavi Daga","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#article","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction"},"author":{"name":"Pallavi Daga","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3"},"headline":"Android EditText : setFilters Example : Numeric Text field Patterns and Length Restriction.","datePublished":"2012-06-04T05:27:52+00:00","dateModified":"2024-11-18T10:36:55+00:00","mainEntityOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction"},"wordCount":233,"commentCount":0,"keywords":["Android","EditText","EditText setFilters","Numeric only EditText"],"articleSection":["Android"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction","name":"Android EditText : setFilters Example : Numeric Text","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#website"},"datePublished":"2012-06-04T05:27:52+00:00","dateModified":"2024-11-18T10:36:55+00:00","author":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3"},"description":"Learn more on Android programming and how to develop Android mobile phone and tablet applications using Android EditText control","breadcrumb":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/android\/android-edittext-setfilters-example-numeric-text-field-patterns-and-length-restriction#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobisoftinfotech.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Android EditText : setFilters Example : Numeric Text field Patterns and Length Restriction."}]},{"@type":"WebSite","@id":"https:\/\/mobisoftinfotech.com\/resources\/#website","url":"https:\/\/mobisoftinfotech.com\/resources\/","name":"Mobisoft Infotech","description":"Discover Mobility","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6007188bd13c6f4297f1e5e2d0ac60c3","name":"Pallavi Daga","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/89ef33292eb327c415fedae5adc889ea2243cf389dce05bfe57552c1d8ba54fc?s=96&r=g","caption":"Pallavi Daga"}}]}},"_links":{"self":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/1614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/comments?post=1614"}],"version-history":[{"count":42,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/1614\/revisions"}],"predecessor-version":[{"id":32185,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/1614\/revisions\/32185"}],"wp:attachment":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media?parent=1614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/categories?post=1614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/tags?post=1614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}