• 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;
         }

    }

  • 相关阅读:
    用DECODE进行排序
    linux下批量替换文件内容
    Linux下chkconfig命令详解
    linux 命令参数列表过长以及find用法
    参数上使用自定义注解在aop中无法获取到该参数
    AOP
    AOP aspect XML 配置
    AOP前世与今生,aspect
    ETL工具之——kettle使用简介
    ETL工具之kittle使用案例整理
  • 原文地址:https://www.cnblogs.com/xl711436/p/3060282.html
Copyright © 2020-2023  润新知