1.布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="helloworld.com.inspur.app4.MainActivity"> <TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hah"
android:id="@+id/tv_1"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hahahh"
android:id="@+id/tv_2"
/>
</LinearLayout>

(2)逻辑代码的实现

package helloworld.com.inspur.app4;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast; public class MainActivity extends AppCompatActivity {
private TextView tv1;
private TextView tv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1=(TextView)findViewById(R.id.tv_1);
tv2=(TextView)findViewById(R.id.tv_2);
tv2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction())
{
case MotionEvent.ACTION_UP:
Toast.makeText(MainActivity.this,"按下",Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_MOVE:
Toast.makeText(MainActivity.this,"移动",Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_DOWN:
Toast.makeText(MainActivity.this,"松开",Toast.LENGTH_SHORT).show();
break;
} return true;
}
}); }
}

最新文章

  1. 小白的CSS基础学习
  2. HighCharts绘制图表
  3. Swift 2.0初探
  4. zw版【转发&#183;台湾nvp系列Delphi例程】HALCON FillUp1
  5. jQuery对象和dom对象的辨析和相互转化
  6. [iOS基础控件 - 3.4] 汤姆猫
  7. 1218.3——init自定义
  8. 转载:MyEclipse安装插件的几种方法
  9. NSTimer的问题
  10. 读书笔记之《深入理解Java虚拟机》不完全学习总结
  11. 一个非常有用的函数—COALESCE
  12. #ifdef #else #endif #if #ifndef 的用法
  13. 洛谷P2144 [FJOI2007]轮状病毒
  14. Luogu P1919 【模板】A*B Problem升级版(FFT快速傅里叶_FFT
  15. Cpython解释器GIL-多线程执行流程
  16. 「2017 山东三轮集训 Day7 解题报告
  17. eclipse中编辑properties文件无法看到中文
  18. 目标检测--Spatial pyramid pooling in deep convolutional networks for visual recognition(PAMI, 2015)
  19. Hi3516CV300 sample -&gt; region
  20. yml转properties

热门文章

  1. bash shell命令与监测的那点事(三)
  2. leetcode 【 Rotate Image 】python 实现
  3. [netty4][netty-common]FastThreadLocal及其相关类系列
  4. 设置CMD默认代码页为65001或936
  5. 使用 htaccess 重写 url,隐藏查询字符串
  6. 菜鸟之路——机器学习之线性回归个人理解及Python实现
  7. MySQL误操作后如何快速恢复数据?
  8. iOS-文本段落样式NSMutableParagraphStyle与NSParagraphStyle的使用和一些富文本处理属性
  9. BZOJ 2818: Gcd(欧拉函数)
  10. CLion 使用笔记(三)