0
Ich habe viele EditText und wenn ich eine Schaltfläche aus deaktiviere ich den Fokus von allen, aber ich bekomme das Ergebnis, dass es der erste EditText hervorgehoben wird, und ich kann diesen Highlighter nicht entfernen. Ich möchte alle die Anfangsbedingung EditExtSo entfernen Sie Highlighter EditText beim Klicken von
private void buttonClick(){
mTxtFld2.setCursorVisible(false);
mTxtFld3.setCursorVisible(false);
mTxtFld4.setCursorVisible(false);
mTxtFld5.setCursorVisible(false);
mTxtFld2.clearFocus();
mTxtFld3.clearFocus();
mTxtFld4.clearFocus();
mTxtFld5.clearFocus();
mTxtFld2.setSelectAllOnFocus(false);
mTxtFld3.setSelectAllOnFocus(false);
mTxtFld4.setSelectAllOnFocus(false);
mTxtFld5.setSelectAllOnFocus(false);
mTxtFld2.setBackgroundColor(Color.TRANSPARENT);
mTxtFld3.setBackgroundColor(Color.TRANSPARENT);
mTxtFld4.setBackgroundColor(Color.TRANSPARENT);
mTxtFld5.setBackgroundColor(Color.TRANSPARENT);
View v = getActivity().getCurrentFocus();
if (v == null) return;
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
In xml
<EditText
android:layout_width="621dp"
android:layout_height="44dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="21dp"
android:id="@+id/EditText2"
android:inputType="textNoSuggestions"
android:fontFamily="fonts/Montserrat-Bold.ttf"
android:selectAllOnFocus="true"
android:gravity="center"
android:singleLine="true"
android:focusable="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:hint="@string/name"
android:textColorHint="@color/text_placeholder"
android:background="@drawable/back" />
Sie können den gesamten Eingabefokus zurücksetzen, indem Sie die Tastatur ausblenden: getWindow(). SetSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN ); –