Android

How to make EditText not editable but scrollable

Posted on

EditText not Editable but Scrollable When we need to show long text like Terms and conditions in EditText. We need to allow scrolling and it should not be editable. For this I tried in XML set EditText attributes to show vertical scrollbars android:scrollbars=”vertical” And then to make EditText not editable i tried different ways like android:inputType=”none” not worked, and […]

Android

Set maxLength of EditText dynamically

Posted on

Set maxLength of EditText dynamically At times you may want to set maxlength of EditText view dynamically. You’ve to use setFilters method of EditText, as shown below. EditText et = new EditText(this); int maxLength = 3; InputFilter[] FilterArray = new InputFilter[1]; FilterArray[0] = new InputFilter.LengthFilter(maxLength); et.setFilters(FilterArray); Hope it helps somebody…Cheers 🙂 You may be also interested in […]

Android

Validation using default feature of EditText

Posted on

Default Validation EditText I found a good article here on how to use the default feature of EditText to show the error. While writing the validation on EditText on a button click event or TextChanged event instead of showing alert dialog if you want to show error we can use the default feature of EditText as EditText […]

Android

Validate a URL / Website name in EditText in Android?

Posted on

Validate a URL / Website To validate URL/ Website name entered in a EditText, this following works fine… private boolean isValidUrl(String url) { Pattern p = Patterns.WEB_URL; Matcher m = p.matcher(url.toLowerCase()); if(m.matches()) return true; else return false; } URL should be in lowercase to validate correctly. Here is ref link. Hope this helps somebody… Cheers…