Creating EditText Programmatically in Android

In this tutorial, I am going to explain how to create a EditText programatically, and the different properties, that we can assign to it in Android.

If we want, our EditText to take only numbers. Then the code is,


For password style implementation, for the editText, the code is,

edit.setTransformationMethod(new android.text.method.PasswordTransformationMethod()

For putting, all letters in caps, the code

InputFilter[] filter = new InputFilter[1];
filter[0] = new InputFilter.AllCaps();

For restricting, only upto this much characters to enter in the editText, the code is,

InputFilter[] filter = new InputFilter[1];
filter[0] = new InputFilter.LengthFilter(15);

In this, I am restricting the characters upto 15 characters.

For moving the editText horizontally or vertically, the code is, Runnablepublic void run() {


Popular posts from this blog

Open Gallery and get the selected image in appplication

Dismiss or Cancel dialog by swipe gesture

AlarmManager and Notification in Android