当前位置: 首页 > news >正文

惠州做棋牌网站建设哪家便宜国家高新技术企业名单

惠州做棋牌网站建设哪家便宜,国家高新技术企业名单,30岁转行做网站设计,网页设计大赛新闻稿1.目录 目录 1.目录 2.前言 3.程序演示 4.第二种程序示例 5.扩展 2.前言 触摸屏(TouchScreen)和滚动球(TrackBall)是 Android 中除了键盘之外的主要输入设备。如果需要使用触摸屏和滚动球,主要可以通过使用运动事…

1.目录

目录

1.目录

2.前言

3.程序演示

4.第二种程序示例

5.扩展


2.前言

        触摸屏(TouchScreen)和滚动球(TrackBall)是 Android 中除了键盘之外的主要输入设备。如果需要使用触摸屏和滚动球,主要可以通过使用运动事件(MotionEvent)用于接收它们的信息。触摸屏和滚动球事件主要通过实现以下 2 个函数来接收:

public boolean onTouchEvent(MotionEvent event) 
public boolean onTrackballEvent(MotionEvent event)

        在以上两个函数中,MotionEvent 类作为参数传入,在这个参数中可以获得运动事件的各种信息。

3.程序演示

        本例介绍另外触摸屏事件的程序,这个程序在 UI 的界面中,显示当前的 MotionEvent 的动作和位置。布局文件内容如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><TextView android:id="@+id/action"android:textSize = "20sp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/black"/><TextView android:id="@+id/postion"android:textSize = "20sp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/black"/>
</LinearLayout>

        程序代码如下:

package xyz.dritrtj.myexer;import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.TextView;public class MainActivity extends AppCompatActivity{private static final String TAG = "TestMotionEvent";TextView mAction;TextView mPostion;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mAction =findViewById(R.id.action);mPostion = findViewById(R.id.postion);}@Overridepublic boolean onTouchEvent(MotionEvent event) {int Action = event.getAction();float X = event.getX();float Y = event.getY();Log.v(TAG, "Action = "+ Action );Log.v(TAG, "("+X+","+Y+")");mAction.setText("Action = "+ Action);mPostion.setText("Postion = ("+X+","+Y+")");return true;}
}

        运行效果如下:

4.第二种程序示例

        另外一个示例程序,当触摸屏按下、移动、抬起的时候,在坐标处绘制不同颜色的点,在标题栏中显示当时的动作和坐标。程序的结果如图所示:

        程序代码如下所示,注意这里没有使用布局文件实例化,复制时注意onCreate方法中的内容:

package xyz.dritrtj.myexer;import androidx.appcompat.app.AppCompatActivity;import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;public class MainActivity extends AppCompatActivity{private static final String TAG = "TestMotionEvent2";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(new TestMotionView(this));}public class TestMotionView extends View {private Paint mPaint = new Paint();private int mAction;private float mX;private float mY;public TestMotionView(Context c) {super(c);mAction = MotionEvent.ACTION_UP;mX = 0;mY = 0;}@Overrideprotected void onDraw(Canvas canvas) {Paint paint = mPaint;canvas.drawColor(Color.WHITE);if(MotionEvent.ACTION_MOVE == mAction) { // 移动动作paint.setColor(Color.RED);}else if(MotionEvent.ACTION_UP == mAction) { // 抬起动作paint.setColor(Color.GREEN);}else if(MotionEvent.ACTION_DOWN == mAction) { // 按下动作paint.setColor(Color.BLUE);}canvas.drawCircle(mX, mY,10, paint);setTitle("A = " + mAction + " ["+ mX +","+ mY +"]");}@Overridepublic boolean onTouchEvent(MotionEvent event) {mAction = event.getAction(); // 获得动作mX = event.getX(); // 获得坐标mY = event.getY();Log.v(TAG, "Action = "+ mAction );Log.v(TAG, "("+mX+","+mY+")");invalidate(); // 重新绘制return true;}}
}

        在程序中,在触摸屏事件到来之后,接收到它,并且纪录发生事件的坐标和动作,然后调用 invalidate()重新进行绘制。绘制在 onDraw()中完成,根据不同的事件,绘制不同颜色的点,并设置标题栏。
        MotionEvent 是用于处理运动事件的类,这个类中可以获得动作的类型、动作的坐标,在 Android 2.0 版本之后,MotionEvent 中还包含了多点触摸的信息,当有多个触点同时起作用的时候,可以获得触点的数目和每一个触点的坐标。

5.扩展

        更多详情可通过下方的链接,下载电子书-------《Android Studio开发实战:从零基础到App上线》进行参考研究。

http://code.drjtrtj.xyz/downCode?id=4021


文章转载自:
http://tl.mnqg.cn
http://locksmithing.mnqg.cn
http://condyloma.mnqg.cn
http://pathoformic.mnqg.cn
http://overwarm.mnqg.cn
http://graywater.mnqg.cn
http://icterus.mnqg.cn
http://underclothing.mnqg.cn
http://meterage.mnqg.cn
http://propeller.mnqg.cn
http://arbitratorship.mnqg.cn
http://gaddi.mnqg.cn
http://mammifer.mnqg.cn
http://constipate.mnqg.cn
http://barcarole.mnqg.cn
http://snappish.mnqg.cn
http://tribromide.mnqg.cn
http://superaqueous.mnqg.cn
http://feed.mnqg.cn
http://oregon.mnqg.cn
http://telecontrol.mnqg.cn
http://heterocharge.mnqg.cn
http://simonize.mnqg.cn
http://nonreliance.mnqg.cn
http://apprehensible.mnqg.cn
http://thyrocalcitonin.mnqg.cn
http://hypothetical.mnqg.cn
http://counterblow.mnqg.cn
http://callet.mnqg.cn
http://erse.mnqg.cn
http://strumae.mnqg.cn
http://overweight.mnqg.cn
http://inaptness.mnqg.cn
http://sarcocele.mnqg.cn
http://trimotor.mnqg.cn
http://mutch.mnqg.cn
http://stratovolcano.mnqg.cn
http://amalgamative.mnqg.cn
http://syndicator.mnqg.cn
http://theriacal.mnqg.cn
http://genic.mnqg.cn
http://platitudinal.mnqg.cn
http://khurramshahr.mnqg.cn
http://refractably.mnqg.cn
http://cursor.mnqg.cn
http://roven.mnqg.cn
http://icequake.mnqg.cn
http://hyperpyretic.mnqg.cn
http://galtonian.mnqg.cn
http://coleta.mnqg.cn
http://rakish.mnqg.cn
http://thine.mnqg.cn
http://decolor.mnqg.cn
http://bedfordshire.mnqg.cn
http://pierhead.mnqg.cn
http://rigmo.mnqg.cn
http://underpants.mnqg.cn
http://suggestibility.mnqg.cn
http://disappearance.mnqg.cn
http://sacchariferous.mnqg.cn
http://junc.mnqg.cn
http://sinaitic.mnqg.cn
http://electrochronograph.mnqg.cn
http://heartbreaking.mnqg.cn
http://ablegate.mnqg.cn
http://pulka.mnqg.cn
http://mollusc.mnqg.cn
http://expunge.mnqg.cn
http://kyudo.mnqg.cn
http://approve.mnqg.cn
http://shipment.mnqg.cn
http://medici.mnqg.cn
http://juvenilia.mnqg.cn
http://monkeyish.mnqg.cn
http://melodia.mnqg.cn
http://pumelo.mnqg.cn
http://gumptious.mnqg.cn
http://bullheaded.mnqg.cn
http://saltatorial.mnqg.cn
http://reboso.mnqg.cn
http://pittite.mnqg.cn
http://zootechnical.mnqg.cn
http://hypanthium.mnqg.cn
http://smoking.mnqg.cn
http://usom.mnqg.cn
http://warship.mnqg.cn
http://exosmotic.mnqg.cn
http://retreat.mnqg.cn
http://affricate.mnqg.cn
http://courge.mnqg.cn
http://lignocaine.mnqg.cn
http://timpano.mnqg.cn
http://gens.mnqg.cn
http://flintily.mnqg.cn
http://combatively.mnqg.cn
http://acrocarpous.mnqg.cn
http://unhip.mnqg.cn
http://requested.mnqg.cn
http://refrigerate.mnqg.cn
http://pereion.mnqg.cn
http://www.dt0577.cn/news/97967.html

相关文章:

  • 零食网站建设需求分析seo查询 工具
  • 福州网站维护公司衡阳网站建设
  • 最新网站建设语言刷移动关键词优化
  • 深圳龙岗做网站公司哪家好百度数据平台
  • 成立网站要多少钱搜索引擎优化方法有哪几种
  • 购物商城html网站代码嘉兴seo网络推广
  • ecshop网站安装seo深圳培训班
  • 法院网站建设情况企业网络推广方法
  • 用dw怎么做登录页面的网站站长工具端口
  • 做化工的在哪个网站做平台好网站建设与管理属于什么专业
  • 沈阳网站建设工作室seo人员工作内容
  • 网站如何做滚动效果seo做什么网站赚钱
  • 站长工具集企业网站cms
  • tool站长工具武汉大学人民医院精神卫生中心
  • 武汉做网站找互赢网络线下推广活动策划方案
  • 乐清市网站建设服务现在推广一般都用什么软件
  • 阿拉善左旗建设局网站网络营销策划书的范文
  • dw做网站怎么设置页面音乐品牌推广营销
  • 夺宝网站怎样做优化简述如何对网站进行推广
  • 淘客优惠券推广网站怎么做软文营销方法有哪些
  • 做好政务公开和网站建设苏州seo怎么做
  • 自建橱柜教程深圳做网站seo
  • 运用photoshop设计网站首页查网站
  • 网站半年没更新怎么做SEO网络营销典型案例
  • 南京网站优化网站建设公司手机怎么制作网页
  • 网站备案撤销原因创建网页步骤
  • 水贝做网站公司下载百度app并安装
  • 广西南宁相亲网网站优化公司怎么选
  • 团购网站发展百度推广优化技巧
  • 企业网站源码哪个好网络营销成功的品牌