android-edittext 키보드가 표시되지 않음
Oct 13 2020
프로그래밍 방식 으로 edittext를 만들고 있습니다. 하지만 편집 텍스트에 아무것도 입력 할 수 없었습니다 . 이 사이트에서 모든 관련 답변을 다루었지만 그중 어느 것도 나를 위해 일하지 않았습니다. 사소한 세부 사항이 누락되었을 수 있습니다. 도움을받을 수 있다면 도움이 될 것입니다.
edittext를 동적으로 생성하는 코드 :
EditText editText = new EditText(dt.c);
editText.setBackground(context.getResources().getDrawable(R.drawable.rectangle_answer));
editText.setTextColor(ContextCompat.getColor(dt.c, R.color.md_black_1000));
editText.setTextSize(16);
editText.setTag(questionDetails[0].getOptionId());
editText.setFocusable(true);
editText.setHint(dt.gStr(R.string.enter_your_answer));
editText.requestFocus();
container.Add(editText);
내가 다룬 몇 가지 답변 :
프로그래밍 방식으로 EditText에 포커스를 설정하고 키보드를 표시하려면 어떻게해야합니까?
Android-프로그래밍 방식으로 키보드를 표시하지 않는 EditText
Android : 버튼을 클릭 할 때 EditText 편집을 위해 키보드를 여는 방법은 무엇입니까?
EditText에서 키보드 비활성화
EditText를 클릭 할 때 키보드를 비활성화하는 방법은 무엇입니까?
답변
1 TrevorSoare Dec 04 2020 at 10:27
나는 동일한 문제를 겪고 있었고 몇 년 전의 게시물 중 하나에서 답을 찾을 때까지 아무것도 작동하지 않았습니다. 앞으로이 문제가 발생할 수있는 사람을 위해 이상한 해킹을 다시 게시 할 것입니다.
xml 파일에서 다음과 같은 더미 편집 텍스트를 최상위 레이아웃 레이어에 추가합니다.
<EditText
android:id="@+id/editTextFix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
tools:targetApi="o"
android:inputType="text"
android:visibility="gone"/>
더미 편집 텍스트는 키보드를 열지 만 프로그래밍 방식으로 생성 된 편집 텍스트에는 여전히 포커스가 있습니다.