Skip to main content

Posts

Showing posts with the label edittext

EditText With Long Default Text On A single Line in ANDROID

Sometimes we may need to include a long default text on a single line in EditText, for that we can set the EditText to single line and provide a horizontal scroll. <EditText android:id="@+id/EditTextValue" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:singleLine="true" android:scrollHorizontally="true" android:text="This is a big text to be included in the edittext so added a horizontal scroll..."/ >

Restrict Edittext input content using Input Filters in ANDROID

InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // TODO Auto-generated method stub for (int i = start; i Here the filters will check whether the input content has only characters from 'a' to 'z'. same way use the condition below to have characters from'a' to 'z' and '0' to '9' and avoid special characters. Character.isLetterOrDigit(source.charAt(i))

Show and Resume Android Soft-Keyboard

Code to show keyboard: InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(yourEditText,InputMethodManager.SHOW_IMPLICIT); Code resume keyboard : InputMethodManager imm = (InputMethodManager)gettSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);