离开后,Android EditText游标停留

时间:2017-07-13 13:46:43

标签: android

我的布局有问题。在布局中,您可以找到很多EditText。 当我点击编辑文本时,弹出对话框显示。但是当我离开输入时,光标停留在。

Five input, Five cursor. Why??

所有edittext都有以下设置:

editText.setFocusable(false);
editText.setClickable(true);
editText.setLongClickable(false);
editText.setTextIsSelectable(false);



 <EditText
        android:id="@+id/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/ic_close_black_24dp"
        android:ems="10"
        android:inputType="textPersonName" />

当我离开输入字段时,如何隐藏光标?

更新:

当我点击“RIGHT DRAWABLE”图标时出现问题。

public static boolean isDrawableClick(MotionEvent event, EditText editText, DrawablePositions drawablePosition) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (editText.getCompoundDrawables()[drawablePosition.position] != null && event.getX() >= (editText.getRight() - editText.getLeft() - editText.getCompoundDrawables()[drawablePosition.position].getBounds().width())) {
                return true;
            }
        }
        return false;
    }

由于

2 个答案:

答案 0 :(得分:0)

使用此

setCursorVisible(false);

答案 1 :(得分:0)

在你的xml中尝试这个

 <EditText
  android:id="@+id/et_edit_account_birth_date"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:focusable="false"
  android:hint="@string/string_birth_date"
  /> 

并在您的活动文件中

et_edit_account_birth_date.setCursorVisible(false);
相关问题