Android的preSS LongClickListener得到X,Y坐标,OnTouchListener [英] Android Press LongClickListener get X, Y Coordinates, OnTouchListener
本文介绍了Android的preSS LongClickListener得到X,Y坐标,OnTouchListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个按钮,并希望使用LongClickListener,以改变按钮的位置在上的按钮获得由pressing的坐标。我怎样才能在LongClickListener或者其他方法得到的X,Y坐标的点击/鼠标。
I have a button and want to use a LongClickListener, to get by pressing on the button the coordinates during changing the position of the button. How can I get in a LongClickListener or perhaps other Method the X,Y coordinates of the Click/Mouse.
我与OnTouchListener试了一下,那是工作。但问题是,TouchListener每次点击反应,不是我想只在pressed。
I tried it with an OnTouchListener, that is working. But the problem is that the TouchListener reacts on each click and not how i want only on pressed.
想法?
关于
推荐答案
做到像在这里OnTouchListener:
do it like here in OnTouchListener:
OnTouchListener mOnTouch = new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
final int action = ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
final int x = (int) ev.getX();
final int y = (int) ev.getY();
break;
}
};
这篇关于Android的preSS LongClickListener得到X,Y坐标,OnTouchListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文