2016-06-10 52 views
0

如果写的文字,它会自动删除,如果点击在十字架上的所有文本从自动填充文本视图中删除,以及如何奶源点击叉号enter image description here如何将删除自动完成文本交叉迹象

+0

你需要的是一个TextWatcher所以当用户在文本字段中输入字符,你可以看到。在这些方法,即:afterTextChanged->你必须编写逻辑来显示你的十字按钮。 – cafebabe1991

回答

1

使用android:drawableRight="@drawable/cross"属性的事件AutoCompleteTextView的。

要处理点击就可以使用下面的代码:

searchMultiAutoCompleteTextView.setOnTouchListener(new OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      final int DRAWABLE_LEFT = 0; 
      final int DRAWABLE_TOP = 1; 
      final int DRAWABLE_RIGHT = 2; 
      final int DRAWABLE_BOTTOM = 3; 

      if(event.getAction() == MotionEvent.ACTION_UP) { 
       if(event.getRawX() >= (searchMultiAutoCompleteTextView.getRight() - searchMultiAutoCompleteTextView.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { 
        // your action here 

       return true; 
       } 
      } 
      return false; 
     } 
    }); 

希望它会为你:)工作

+0

也想处理点击我的片段...... –

+0

我已经添加了代码来处理点击十字按钮。希望它能起作用。 :) – Neo

+0

thanx neo其工作酷 –