答案 0 :(得分:1)
使用AutoCompleteTextView的android:drawableRight="@drawable/cross"
属性。
要处理点击,您可以使用以下代码:
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;
}
});
希望它对您有用:)