To answer my own question...

Use TextView.setCompoundDrawables(null, null, null, null) to hide the
cross.

Next thing is to detect when the cross is pressed on.

Currently I do this:

mEditText.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
                if (mEditText.getCompoundDrawables()[2] == null) {
                        // cross is not being shown so no need to handle
                        return false;
                }
                if (event.getAction() != MotionEvent.ACTION_DOWN) {
                        // only respond to the down type
                        return false;
                }
                if (event.getX() > mEditText.getMeasuredWidth() -
mEditText.getPaddingRight() - x.getIntrinsicWidth()) {
                        mEditText.setText("");
                        return true;
                }
                else {
                        return false;
                }
        }
});

This works but feels rather messy to me. Also, I'm not sure about the
mEditText.getPaddingRight()...

Is there a better way?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to