티스토리 뷰
먼저, EditText 의 커스텀 키보드를 제작하는 방법입니다. ↓
EditText 커스텀 키보드 제작키보드를 만들었다면 해당 메소드를 구현합니다.
1. 커서 위치부터 한칸 지우기.
커스텀 키보드의 BackSpace 등 개발자가 지우길 원하는 버튼을 눌렀을 경우의 이벤트.
public void backBTN(EditText et){ // EditText 커서 position을 구합니다. int selection = et.getSelectionStart(); // 커서 position 이 0이라면, nullpointer exception occur.. 종료합니다. if(selection == 0){ return; } // position을 기준으로 두 구간 분리. // ex) "123456"에서 커서가 3 뒤에 있다면 "123"과 "456"으로 ��눕니다. // 여기서 3을 지우고 "12"와 "456"을 붙여줍니다. phoneno = phoneno.substring(0, selection - 1) + phoneno.substring(selection, phoneno.length()); et.setText(phoneno); // editText position을 ��재 position�� 한칸 앞으로 이동시킵니다. et.setSelection(selection-1); }
2. 커서 위치부터 한글자 추가하기.
/** * ��재 커서 위��에서 한글자(add) 추가 * @param phoneno */ public void inputPad(EditText et, String add){ // ��재 커서위��를 구한다. int selection = et.getSelectionStart(); phoneno = phoneno.substring(0, selection) + add + phoneno.substring(selection, phoneno.length()); et.setText(phoneno); setCursorPosition(selection + 1); }
'Computer > Android&iOS' 카테고리의 다른 글
ActionBar 로 Tab을 만들때 인접 Tab까지 같이 불리는 현상 (0) | 2014.03.07 |
---|---|
Fragment 에서 getContentResolver() 사용하기 (0) | 2014.03.07 |
(Android) EditText 키보드 숨기고, 커서는 보이게 하기(키보드 커스터마이징) (0) | 2014.03.06 |
TabActivity 와 ActivityGroup 는 deprecated 되었습니다. (0) | 2014.03.06 |
(안드로이드) Incorrect line ending: ... .에러 (0) | 2014.02.20 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- BBC 가쉽
- 리눅스
- git hub
- xcode
- 앵커브리핑
- 노드
- Swift
- Kotlin
- 안드로이드
- IOS
- CentOS
- GIT
- 서버
- 점유율
- Android
- 스위프트
- C
- Phaser
- Asterisk
- 깃헙
- nodejs
- Node
- 손석희
- linux
- php
- node.js
- 배열
- mysql
- 뉴스룸
- C언어
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함