zoukankan      html  css  js  c++  java
  • 04_响应单点触控


    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.MotionEvent;
    import android.view.View;
    import android.view.View.OnTouchListener;
    import android.widget.TextView;

    public class MainActivity extends Activity implements OnTouchListener {

      StringBuilder builder = new StringBuilder();
         TextView textView;

         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             textView = new TextView(this);
             textView.setText("Touch and drag (one finger only)!");
             textView.setOnTouchListener(this);
             setContentView(textView);
         }

         @Override
         public boolean onTouch(View v, MotionEvent event) {
             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;
         }

    }

  • 相关阅读:
    (转)VC++多线程编程
    英文缩写汇总
    SINGLETON(单件)——对象创建型模式
    指针地址的修改
    我在csdn博客中的一些总结
    listener的执行先后问题
    css的精髓是布局,而不是样式——之三
    Jo——一个简单HTML5移动框架介绍
    深入了解javascript中的exec与match方法
    多ajax查询模拟一个整体的查询事务
  • 原文地址:https://www.cnblogs.com/xl711436/p/3060282.html
Copyright © 2011-2022 走看看