如何使用触摸侦听器执行Url?

时间:2015-11-28 11:41:26

标签: android

如何在按下按钮时执行url,并在释放时再执行另一个url。 我在这里使用触摸侦听器是代码,但它不起作用。

public boolean onTouch(View v, MotionEvent event) {
    switch (v.getId()) {
        case R.id.Cam_up:
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                String upUrl = "up";
                task.execute(upUrl);
            } else {
                stop.execute();
            }
            break;
        case R.id.Cam_down:
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                String DownUrl = "down";
                task.execute(DownUrl);
            } else {
                stop.execute();
            }
            break;
        case R.id.Cam_right:
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                String RightUrl = "right";
                task.execute(RightUrl);
            }else {
                stop.execute();
            }
            break;
        case R.id.Cam_left:
            if (event.getAction() == MotionEvent.ACTION_DOWN) {

                String LeftUrl = "left";
                task = new StartRotation();
                task.execute(LeftUrl);
            }else {
                stop.execute();
            }
            break;
    }
    return true;
}

我该怎么办?

0 个答案:

没有答案