EditText에 대한 자동 제안을 끄시겠습니까?
EditText에 입력 할 때 팝업되는 자동 제안 목록을 프로그래밍 방식으로 끄는 방법이 있습니까?
나는 같은 질문을했지만 XML 파일 에이 옵션을 설정하고 싶었으므로 직접 찾을 때까지 조금 더 조사했습니다.
이 줄을 EditText에 추가하십시오.
android:inputType="textFilter"
여기 팁이 있습니다. "enter"키를 사용하려면이 줄을 사용하십시오.
android:inputType="textFilter|textMultiLine"
android:inputType="textNoSuggestions"
android:inputType="textVisiblePassword"
매력처럼 작동합니다
프로그래밍 방식으로
edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
XML
android:inputType="textNoSuggestions|textVisiblePassword"
자동 완성을 제거하는 가장 신뢰할 수있는 방법은
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
EditText 컨트롤에서. Charlie가이 페이지에서 다른 답변으로보고 한 것처럼
android:inputType="textVisiblePassword"
이 플래그의 XML 버전입니다.
이 플래그를
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
대부분의 전화에서 작동하는 InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD없이 InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS를 사용하고 있었지만 여전히 자동 완성되는 Samsung 전화를 보았습니다.
Android는 에뮬레이터의 EditText에 대해 자동 완성 / 자동 제안을 프로그래밍 방식으로 비활성화합니다.
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD 사용을 제안했습니다.
나는 이것을 InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS와 함께 시도해 보았습니다. 자동 완성을 원하지 않는 힌트를 얻지 못하는 전화조차도 암호 필드에 대해 비활성화 해야하는 이유를 알 수 있습니다. 숨을들이 마시지 못하는 것은이 전화에서 원하는 것을 얻는 가장 좋은 방법 일 수 있습니다.
내 장치 중 일부에서 글꼴 이이 플래그에 의해 약간 변경되었습니다. 가장 눈에 띄게 0과 Oh (O)를 더 명확하게 구별하는 것이 암호를 표시하는 데 중요합니다. 그러나 적어도 효과가 있었고 새로운 글꼴은 매력적이지 않았습니다.
이 제안을 찾은 게시물이 오래되었지만 내가 테스트 한 전화는 Sprint의 Samsung Galaxy Note II (SPH-L900) 재고 Android 4.1.2입니다. 선택한 키보드는 "Samsung Keyboard"였으며 고객이 Sprint에서 키보드를 받았을 때의 기본값이었습니다. 따라서이 문제는 수년 동안 삼성의 중요한 전화선 중 일부에 대해 지속되었습니다.
나와 같은 삼성 테스트 장치가없는 사람들에게는 이것이 중요한 정보가 될 수 있습니다.
안드로이드 버전 8.0 이상의 경우이 코드가 작동하지 않고 자동 완성 텍스트 뷰의 경우이 코드도 작동하지 않으므로 8.0 이상의 안드로이드 자동 제안 사용 안함에 대해 아래 코드를 사용하는 것이 좋습니다 . importantForAutofill = "no"
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"
android:imeOptions="actionDone"
android:maxLength="80"
android:maxLines="1"
android:textColor="@color/colorBlack"
android:textColorHint="@color/colorBlack"
android:importantForAutofill="no"
android:textSize="@dimen/_12sdp"
app:bFontsEdt="light" />
이 자동 완성 텍스트보기의 경우이 필드를 사용하여 자동 제안 android : importantForAutofill = "no" 를 비활성화하십시오 .
<AutoCompleteTextView
android:id="@+id/autocompleteEditTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_3sdp"
android:layout_marginTop="@dimen/_5sdp"
android:background="@null"
android:imeOptions="actionDone"
android:singleLine="true"
android:text=""
android:textColor="@color/colorBlack"
android:textColorHint="@color/colorGrayDark"
android:importantForAutofill="no"
android:textSize="@dimen/_12sdp" />
이것은 여전히 문제 이므로이 답변을 게시 할 것입니다. android : inputType = "textVisiblePassword"는 작동하지만 먼저 입력을 잘못 표시하기 때문에 바람직하지 않으며, 두 번째로 제스처 입력을 사용하지 않기 때문에 바람직하지 않습니다!
대신 BOTH 플래그 textNoSuggestions 및 textFilter를 사용해야했습니다. 하나만으로는 효과가 없었습니다.
android:inputType="textCapSentences|textFilter|textNoSuggestions"
The textCapSentences was for other reasons. But this inputType kept the swipe typing and disabled the suggestion toolbar.
I was getting this thing on samsung phones running 4.4.4. This solved my problem
android:inputType="text|textVisiblePassword|textNoSuggestions"
OK, the problem was - in Eclipse you don't get suggestion for flag named: textNoSuggestion
And you can't set it in main.xml (where you design UI) because that attribute for inputType isn't recognized. So you can set it in code using int const:
EditText txtTypeIt = (EditText) this.findViewById(R.id.txtTypeIt);
txtTypeIt.setInputType(524288);
And thanks jasta00 for helping me out figure answer for this one.
EditText emailTxt=(EditText)findViewById(R.id.email);
emailTxt.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
This will help you.
android:inputType="text|textNoSuggestions"
You could simply use the EditText's setThreshold()
method. Set the threshold to let's say 100 when you don't want to show predictions. If you want to re-activate showing predictions, set it back to a small int like 1 or 2 depending on your needs.
// 100% correct & tested
txtKey = (EditText) view.findViewById(R.id.txtKey);
txtKey.setPrivateImeOptions("nm");
txtKey.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
txtKey.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}
참고URL : https://stackoverflow.com/questions/1959576/turn-off-autosuggest-for-edittext
'Programing' 카테고리의 다른 글
Angular에서는 배열에서 객체를 검색해야합니다. (0) | 2020.07.22 |
---|---|
쉘 스크립트에서 대소 문자를 구분하지 않는 문자열 비교 (0) | 2020.07.22 |
iOSTableView는 iOS 7에서 오프셋으로 시작합니다. (0) | 2020.07.22 |
Java에서 int의 스트림을 char의 스트림으로 변환 (0) | 2020.07.22 |
Cordova : 특정 iOS 에뮬레이터 이미지 시작 (0) | 2020.07.22 |