当前位置: 代码迷 >> Android >> android中如何获得MotionEvent.ACTION_MOVE中的起始点
  详细解决方案

android中如何获得MotionEvent.ACTION_MOVE中的起始点

热度:93   发布时间:2016-05-01 11:00:55.0
android中怎么获得MotionEvent.ACTION_MOVE中的起始点
因为要获得ListView这个组件里的滑动起始点,但不知道怎么获得。
android listview ACTION_MOVE

------解决方案--------------------
实现OnTouchListener接口,对MotionEvent.ACTION_DOWN进行处理
例如:
public boolean onTouch(View v, MotionEvent event) {  
        // TODO Auto-generated method stub  
        builder.setLength(0);  
        switch(event.getAction()){  
        case MotionEvent.ACTION_DOWN:  
            builder.append("down, ");  
            break;  
        case MotionEvent.ACTION_MOVE:  
            builder.append("move, ");  
            break;  
        case MotionEvent.ACTION_CANCEL:  
            builder.append("cancle, ");  
            break;  
        case MotionEvent.ACTION_UP:  
            builder.append("up, ");  
            break;  
        }  
        builder.append(event.getX());  
        builder.append(", ");  
        builder.append(event.getY());  
        String text = builder.toString();  
        Log.d("TouchTest", text);  
        textView.setText(text);  
        return true;  
    }  

------解决方案--------------------
listview.setTag(id,event.getY());这是在down里做的记号   
得到是  直接 getTag(id);
  相关解决方案