반응형
안드로이드(Android) EditText 위젯의 입력타입별 예제 |
환경 : Eclipse Mars, Android 4.2.2 |
이번예제는 값을 입력할수 있는 EditText 위젯의 여러 형태가 어떤식으로 구현되는지 알아보는 샘플입니다. 한줄 입력하는 기본 텍스트 입력창 외에 비밀번호 입력을 받는 입력창, 여러 줄을 입력할 수 있는 입력창 등 옵션 조절로 상황에 맞게 구현이 가능합니다.
▼ 샘플에는 기본입력창과 패스워드 입력할 때 보안을 위해 텍스트 대신 점을 표시해주는 EditText 가 있습니다. 패스워드 입력창은 옵션을 android:password="true" 로 설정하시면 됩니다.
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:password="true" />
▼ 여러 줄을 입력할수 있는 창은 android:inputType="text|textMultiLine" 으로 설정하고 최소라인 크기를 설정하면 됩니다.
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="top" android:inputType="text|textMultiLine" android:minLines="3" />
▼ 날짜 입력창은 날짜와 관련된 값이외에는 입력이 안됩니다. inputType 을 date 로
설정하면 됩니다.
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="date" />
▼ EditText 에 숫자만 입력가능하도록 유효성 검사기능을 넣을 수도 있습니다.
아래 예제는 소수점을 위한 콤마도 들어갑니다.
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="number|numberSigned|numberDecimal" />
반응형
'안드로이드 개발' 카테고리의 다른 글
안드로이드(Android) 행열(Matrix) 클래스의 postConcat() 함수이용해 거울이미지구현 (0) | 2015.01.25 |
---|---|
안드로이드(Android) 비트맵 이미지를 다양한 방법으로 변형하는 예제 (0) | 2015.01.19 |
안드로이드(Android) 이미지다운로드해서 Sdcard 에 저장하기 (3) | 2015.01.15 |
안드로이드(Android) AutoCompleteTextView 위젯을 이용해 단어 자동완성기능 구현 (0) | 2015.01.12 |
안드로이드(Android) raw 폴더에 있는 Text 파일 읽어 오기 (1) | 2015.01.08 |
안드로이드(Android) Chronometer 사용하여 시간측정을 위한 타이머 만들기 (1) | 2015.01.05 |
안드로이드(Android) Chronometer, OnChronometerTickListener 통해 시간알아오기 (2) | 2015.01.04 |
안드로이드(Android) 웹페이지에서 이미지 다운로드 구현 (0) | 2015.01.01 |
녹두장군1님의
글이 좋았다면 응원을 보내주세요!