[안드로이드 Compose] TextField, 완료시 다음 TextField로 이동

2023. 3. 5. 01:05·안드로이드
728x90
반응형

먼저 keyboardOption에서 ImeAction.Next를 인자로 넘겨주자.

 

OutlinedTextField(
    ...
    
    keyboardOptions = KeyboardOptions(
    	keyboardType = type, 
        imeAction = ImeAction.Next
    )
    
	...
)

 

처음에는 옵션만 지정해주면 되는줄 알았는데, Action도 같이 지정해줘야한다. 

 

ImeAction.Next를 지정했으므로 Next에 대한 행동을 정의해줘야한다.

 

먼저 FocusManager를 통해 포커싱된 TextField의 위치를 잡고, 그 아래 방향으로 포커싱을 맞춰야한다.

 

OutlinedTextField(
    ...

    keyboardOptions = KeyboardOptions(
        keyboardType = type,
        imeAction = imeAction
    ),

    keyboardActions = KeyboardActions (
        onDone = {
            focusManager.clearFocus(true)
        },
        onNext = {
            focusManager.moveFocus(FocusDirection.Down)
        }
    )
    ...
)

 

추가적으로 포커싱을 없애는 코드를 넣었다.

참고

https://stackoverflow.com/questions/71870416/how-shift-request-focus-to-next-textfield-in-jetpack-compose

 

How shift Request Focus to next textfield in Jetpack compose

My requirement is when I enter 1 digit in text field after entering it should be shifted to next text field. Everywhere I got the answer like this. In short I'm looking for similar functionality like

stackoverflow.com

 

https://blog.canopas.com/keyboard-handling-in-jetpack-compose-all-you-need-to-know-3e6fddd30d9a

 

Keyboard Handling In Jetpack Compose — All You Need To Know

Whether you are a beginner or an experienced dev, you’ll find yourself dealing with the keyboard APIs. Here’s the guide to master it.

blog.canopas.com

 

'안드로이드' 카테고리의 다른 글

[안드로이드] 'libuvc/libuvc_config.h' file not found 에러  (2) 2023.02.20
[안드로이드] USB camera 연결 시, 항상 permission denied인 경우  (0) 2023.02.18
[안드로이드] PreviewView가 다른 View를 overlap하는 경우  (0) 2023.02.11
[안드로이드] 앱 강제 종료  (0) 2023.02.10
[안드로이드] getBitmap 메서드와 성능  (1) 2023.01.19
'안드로이드' 카테고리의 다른 글
  • [안드로이드] 'libuvc/libuvc_config.h' file not found 에러
  • [안드로이드] USB camera 연결 시, 항상 permission denied인 경우
  • [안드로이드] PreviewView가 다른 View를 overlap하는 경우
  • [안드로이드] 앱 강제 종료
uinone
uinone
노는 게 제일 좋아😉
  • uinone
    ideaDummy
    uinone
  • 전체
    오늘
    어제
    • 분류 전체보기
      • CS
        • 확률과 통계
        • 자료구조
        • 논리회로
        • OS
        • 데이터 통신
        • 데이터 과학
        • 컴파일러
      • 알고리즘
        • 그리디
      • 컴퓨터 비전
      • 안드로이드
      • Web
        • CSS
        • TypeScript
        • React.js
      • 기타
        • 모각코
        • 메모장
        • 오류해결
        • 풍미박산 기절초풍 설치과정
      • DL
      • ML
      • 언어
        • C
        • Ocaml
      • Tensorflow
      • 8기 글로벌 SW*AI인재 프로그램
      • 논문 정리
        • 3D Object Detection
        • 3D Multi Object Tracking
      • CUDA
      • Dataset
        • NuScenes
  • 블로그 메뉴

    • LinkedIn
    • Github
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    우선순위 큐
    백준
    그리디 알고리즘
    NetworkFlow
    정렬
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
uinone
[안드로이드 Compose] TextField, 완료시 다음 TextField로 이동
상단으로

티스토리툴바