package com.example.memosystem.activity.listen;

import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

public class TouchListen implements View.OnTouchListener{


    private EditText ed=null;

    public  TouchListen(EditText ed){
        this.ed=ed;
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {


        //
        int start=ed.getWidth()-ed.getPaddingEnd()-ed.getPaddingRight();
        int end=ed.getWidth();//整个文本的宽带

        float x = motionEvent.getX();


        boolean isButtonClicked=x>start&&x<end;
        if(isButtonClicked){

            if(motionEvent.getAction()==MotionEvent.ACTION_UP){
                //判断是否鼠标抬起
                ed.setText("");
                return true;
            }

        }
        return false;
    }
}
