안드로이드 개발 질문/답변
(글 수 45,052)
앤터키를 눌렀을때 포커스 이동 법은 android:nextFocusDown="@+id/??????"
이렇게 하면 되는데요.
그렇다면 EditText에 입력하는 값의제한이 있을경우 이 제한값까지 입력했을때
다음 EditText로 포커스가 넘어가게 하는 방법이 궁금 합니다..
결론은... 다른 EditText로 포커스를 어캐 넘길까요..?
도움 부탁 드립니다~~
2010.11.05 09:52:03
해보지는 않았는데요.
requestFocus 라는 함수가 있는데요.
EditText 에 이벤트 중에 문자 업력 때마다 들어오는 이벤트가 있잖아요.
거기서 입력 된 값의 길이를 체크해서 특정 길이가 되면 다른 EditBox에다가 requestFoucs 함수를 호출해 주면 어떨까요.;ㅁ;
2010.11.24 10:28:59
첫번째 EditText의 id값 을 --> edit1이라하고 두번째 EditText의 id값 을 --> edit2 이라하면
edit1.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(edit1.length()==6){ // edit1 값의 제한값을 6이라고 가정했을때
edit2.requestFocus(); // 두번째EditText 로 포커스가 넘어가게 됩니다
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {}
});



