제가 CustomView를 다음과 같이 만들어두었습니다.
<RelativeLayout>
<EditText>
<NumberPicker>
<ImageView>
</RelativeLayout>
그리고 커스텀뷰를 포함하고 있는 리사이클러 아이템뷰를 생성했습니다.
<LinearLayout>
<CustomView>
<CustomView>
<CheckBox>
</LinearLayout>
저는 여기서 editText의 입력이 끝났을때, doneButton or NextButton을 소프트키보드에서 터치하면 다음 editText로 포커스가 이동하는걸 구현하려고 합니다.
https://stackoverflow.com/questions/48035761/change-focus-sequence-on-next-press-button-in-recyclerview
이 질문과 완전 흡사해요 ㅠㅠ
혹시 포커스를 다음으로 넘기는 방법을 아시는 고수님 계실까요? 일주일째 잡고있습니다 ㅠ 제발 도와주세요
제가 시도해봤지만 실패한 방법은 다음과 같습니다..
1.
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/workout_today_routine_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
/>
+ manifest에 softInputMode 추가
android:windowSoftInputMode="stateHidden|adjustPan"
결과 : 다음버튼 클릭시 키보드 사라짐 + 포커스 이동 안함
2. editText에 속성주기
<EditText
android:layout_width="72dp"
android:layout_height="36dp"
android:textSize="15dp"
android:gravity="center"
android:layout_centerInParent="true"
android:text="1"
android:singleLine="true"
android:maxLines="1"
android:inputType="number"
android:background="@null"
android:imeOptions="actionNext"
/>
결과 : 다음버튼 클릭시 키보드 사라짐 + 포커스 이동 안함
3. onBindViewHolder에서 코드로 접근
public void setFocusNextView(View nextView){
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE || actionId==EditorInfo.IME_ACTION_NEXT){
mEditText.clearFocus();
if (nextView != null){
nextView.setFocusable(true);
nextView.requestFocus();
if (nextView instanceof EditText) ((EditText)nextView).setSelection(((EditText)nextView).getText().toString().length());
}
}
return false;
}
});
}
결과 : 다음버튼 클릭시 키보드 사라짐 + 포커스 이동 안함
4. onBindViewHolder에서 코드로 접근
mEditTextView.setNextFocusDownId(nextViewId);
5. 그 외에도 attr 을 받아와서 xml에서 다음과 같은 속성을 적용해봤는데도 변화가 없었습니다...
android:nextFocusRight="@id/custom_number_picker_second"
혹시라도 비슷한 문제를 해결해보신 분 계실까요?
리사이클러뷰 안에서 포커스 관리... 너무 어렵네요ㅠ