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,
edit.setInputType(InputType.TYPE_CLASS_NUMBER);
For password style implementation, for the editText, the code is,
edit.setTransformationMethod(new android.text.method.PasswordTransformationMethod()
.getInstance());
For putting, all letters in caps, the code
InputFilter[] filter = new InputFilter[1];
filter[0] = new InputFilter.AllCaps();
edit.setFilters(filter);
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);
edit.setFilters(filter);
In this, I am restricting the characters upto 15 characters.
For moving the editText horizontally or vertically, the code is,
edit.post(new Runnablepublic void run() {
edit.offsetLeftAndRight(50);
edit.offsetTopAndBottom(100);
}
});
If we want, our EditText to take only numbers. Then the code is,
edit.setInputType(InputType.TYPE_CLASS_NUMBER);
For password style implementation, for the editText, the code is,
edit.setTransformationMethod(new android.text.method.PasswordTransformationMethod()
.getInstance());
For putting, all letters in caps, the code
InputFilter[] filter = new InputFilter[1];
filter[0] = new InputFilter.AllCaps();
edit.setFilters(filter);
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);
edit.setFilters(filter);
In this, I am restricting the characters upto 15 characters.
For moving the editText horizontally or vertically, the code is,
edit.post(new Runnablepublic void run() {
edit.offsetLeftAndRight(50);
edit.offsetTopAndBottom(100);
}
});
'Android' 카테고리의 다른 글
sync 상태 얻어오는 방법!! (0) | 2010.04.26 |
---|---|
[넥서스원] KT의 3G인터넷과 MMS설정을 위한 정보 (리셋시 필요합니다.) (0) | 2010.04.07 |
안드로이드에서 화면 회전시 나타나는 문제- Android Screen Rotation Issue (0) | 2010.03.23 |
가로,세로 모드 변경시 호출되는 함수 (0) | 2010.03.02 |
android 애러 대처법 : emulator: ERROR: bad config: virtual device directory lacks config.ini (0) | 2010.02.28 |