What’s the best way to limit text length of EditText in Android
Documentation Example android:maxLength=”10″
Documentation Example android:maxLength=”10″
Best method is to use: etUsername.setLongClickable(false);
I did something like this once; EditText usernameEditText = (EditText) findViewById(R.id.editUsername); sUsername = usernameEditText.getText().toString(); if (sUsername.matches(“”)) { Toast.makeText(this, “You did not enter a username”, Toast.LENGTH_SHORT).show(); return; }
Setting the android:textCursorDrawable attribute to @null should result in the use of android:textColor as the cursor color. Attribute “textCursorDrawable” is available in API level 12 and higher
First make this class : package com.test; import android.text.InputFilter; import android.text.Spanned; public class InputFilterMinMax implements InputFilter { private int min, max; public InputFilterMinMax(int min, int max) { this.min = min; this.max = max; } public InputFilterMinMax(String min, String max) { this.min = Integer.parseInt(min); this.max = Integer.parseInt(max); } @Override public CharSequence filter(CharSequence source, int start, int … Read more
I had same issues. Try following code: android:windowSoftInputMode=”adjustPan” add it to your manifest.xml in the activity tag of the activity that holds the input. example: <activity android:name=”.Activities.InputsActivity” … android:windowSoftInputMode=”adjustPan” />
I found this on another forum. Works like a champ. InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i))) { return “”; } } return null; } }; edit.setFilters(new InputFilter[] { … Read more
For use of the TextWatcher… et1.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub … Read more
This helped me. In your manifest : <activity android:name= “.yourActivity” android:windowSoftInputMode=”adjustPan”/>
How to stop EditText from gaining focus when an activity starts in Android?