Carson带你学Android:手把手教你学会手势识别应用 GestureDetector

本文主要是介绍Carson带你学Android:手把手教你学会手势识别应用 GestureDetector,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言

  • 手势识别在Android开发的应用非常常见
  • 今天carson将详细给大家讲解Android手势识别类:GestureDetector类的使用。(含实例讲解)

Carson带你学Android系列文章
Carson带你学Android:学习方法
Carson带你学Android:四大组件
Carson带你学Android:自定义View
Carson带你学Android:异步-多线程
Carson带你学Android:性能优化
Carson带你学Android:动画


目录


简介

下面,我将结合实例,详细介绍GestureDetector的使用接口 & 使用类。


接口1:OnGestureListener

1. 作用

检测用户在屏幕的以下操作:按下瞬间、按压、长按、轻击、快速滑屏、拖动

2. 使用步骤

// 步骤1:创建手势检测器实例 & 传入OnGestureListener接口(需要复写对应方法)
// 构造函数有3个,常用的是第二个
// 1. GestureDetector gestureDetector=new GestureDetector(GestureDetector.OnGestureListener listener);
// 2. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.OnGestureListener listener);
// 3. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.SimpleOnGestureListener listener);GestureDetector mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}});// 步骤2-1:让某个View检测手势 - 重写View的onTouch函数,将View的触屏事件交给GestureDetector处理,从而对用户手势作出响应View.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return true; // 注:返回true才能完整接收触摸事件}});// 步骤2-2:让某个Activity检测手势:重写Activity的dispatchTouchEvent函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应@Overridepublic boolean dispatchTouchEvent(MotionEvent ev) {mGestureDetector.onTouchEvent(ev); // 让GestureDetector响应触碰事件super.dispatchTouchEvent(ev); // 让Activity响应触碰事件return false;}

3. 实例说明

现在对一个TextView进行手势检测
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="match_parent"android:layout_height="600dp"android:text="carson_ho Test"android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {TextView mTextView;GestureDetector mGestureDetector;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 步骤1:创建手势检测器实例 & 传入OnGestureListener接口(需要复写对应方法)mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}});// 步骤2:让TextView检测手势:重写View的onTouch函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应mTextView = (TextView) findViewById(R.id.textView);mTextView.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return false;}});}
}

4. 示意图

我在屏幕作出一系列手势进行测试


接口2:OnDoubleTapListener

1. 作用

检测用户单击、双击屏幕

2. 使用步骤

// 步骤1:创建手势检测器实例// 注:使用OnDoubleTapListener接口时,需要使用GestureDetector,而GestureDetector的创建则必须传入OnGestureListener接口// 所以在使用OnDoubleTapListener接口时,也必须实现OnGestureListener接口// 构造函数有3个,常用的是第二个// 1. GestureDetector gestureDetector=new GestureDetector(GestureDetector.OnGestureListener listener);// 2. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.OnGestureListener listener);// 3. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.SimpleOnGestureListener listener);GestureDetector mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}});// 步骤2:创建 & 设置OnDoubleTapListener接口实现类mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {// 1. 单击事件// 关于OnDoubleTapListener.onSingleTapConfirmed()和 OnGestureListener.onSingleTapUp()的区别// onSingleTapConfirmed:再次点击(即双击),则不会执行// onSingleTapUp:手抬起就会执行public boolean onSingleTapConfirmed(MotionEvent e) {Log.i("MyGesture", "onSingleTapConfirmed");return false;}// 2. 双击事件public boolean onDoubleTap(MotionEvent e) {Log.i("MyGesture", "onDoubleTap");return false;}// 3. 双击间隔中发生的动作// 指触发onDoubleTap后,在双击之间发生的其它动作,包含down、up和move事件;public boolean onDoubleTapEvent(MotionEvent e) {Log.i("MyGesture", "onDoubleTapEvent");return false;}});// 步骤3-1:让某个View检测手势 - 重写View的onTouch函数,将View的触屏事件交给GestureDetector处理,从而对用户手势作出响应View.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return true; // 注:返回true才能完整接收触摸事件}});// 步骤3-2:让某个Activity检测手势:重写Activity的dispatchTouchEvent函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应@Overridepublic boolean dispatchTouchEvent(MotionEvent ev) {mGestureDetector.onTouchEvent(ev); // 让GestureDetector响应触碰事件super.dispatchTouchEvent(ev); // 让Activity响应触碰事件return false;}

3. 实例说明

现在对一个TextView进行手势检测
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="match_parent"android:layout_height="600dp"android:text="carson_ho Test"android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {TextView mTextView;GestureDetector mGestureDetector;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 步骤1:创建手势检测器实例 & 传入OnGestureListener接口(需要复写对应方法)mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture1", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}});// 步骤2:创建 & 设置OnDoubleTapListener接口实现类mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {// 1. 单击事件// 关于OnDoubleTapListener.onSingleTapConfirmed()和 OnGestureListener.onSingleTapUp()的区别// onSingleTapConfirmed:再次点击(即双击),则不会执行// onSingleTapUp:手抬起就会执行public boolean onSingleTapConfirmed(MotionEvent e) {Log.i("MyGesture", "onSingleTapConfirmed");return false;}// 2. 双击事件public boolean onDoubleTap(MotionEvent e) {Log.i("MyGesture", "onDoubleTap");return false;}// 3. 双击间隔中发生的动作// 指触发onDoubleTap后,在双击之间发生的其它动作,包含down、up和move事件;public boolean onDoubleTapEvent(MotionEvent e) {Log.i("MyGesture", "onDoubleTapEvent");return false;}});// 步骤3:重写View的onTouch函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应mTextView = (TextView) findViewById(R.id.textView);mTextView.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return true;}});}
}

4. 测试效果

日志效果如下


使用类:SimpleOnGestureListener

1. 作用

集成了两个接口的手势检测功能

2. 与上述两个接口的区别

  • OnGestureListener和OnDoubleTapListener接口里的函数都是强制必须重写的
  • 而SimpleOnGestureListener类的函数则可根据需要选择性复写,因为SimpleOnGestureListener类本身已经实现了这两个接口的所有函数,只是里面全是空的而已

3. 使用步骤

// 步骤1:创建手势检测器实例// 构造函数有3个,此处用的是第三个// 1. GestureDetector gestureDetector=new GestureDetector(GestureDetector.OnGestureListener listener);// 2. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.OnGestureListener listener);// 3. GestureDetector gestureDetector=new GestureDetector(Context context,GestureDetector.SimpleOnGestureListener listener);GestureDetector mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {// OnGestureListener接口的函数// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture1", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}// OnDoubleTapListener的函数// 1. 单击事件// 关于OnDoubleTapListener.onSingleTapConfirmed()和 OnGestureListener.onSingleTapUp()的区别// onSingleTapConfirmed:再次点击(即双击),则不会执行// onSingleTapUp:手抬起就会执行public boolean onSingleTapConfirmed(MotionEvent e) {Log.i("MyGesture", "onSingleTapConfirmed");return false;}// 2. 双击事件public boolean onDoubleTap(MotionEvent e) {Log.i("MyGesture", "onDoubleTap");return false;}// 3. 双击间隔中发生的动作// 指触发onDoubleTap后,在双击之间发生的其它动作,包含down、up和move事件;public boolean onDoubleTapEvent(MotionEvent e) {Log.i("MyGesture", "onDoubleTapEvent");return false;}});// 步骤2-1:让某个View检测手势 - 重写View的onTouch函数,将View的触屏事件交给GestureDetector处理,从而对用户手势作出响应View.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return true; // 注:返回true才能完整接收触摸事件}});// 步骤2-2:让某个Activity检测手势:重写Activity的dispatchTouchEvent函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应@Overridepublic boolean dispatchTouchEvent(MotionEvent ev) {mGestureDetector.onTouchEvent(ev); // 让GestureDetector响应触碰事件super.dispatchTouchEvent(ev); // 让Activity响应触碰事件return false;}

4. 实例说明

现在对一个TextView进行手势检测
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="match_parent"android:layout_height="600dp"android:text="carson_ho Test"android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {TextView mTextView;GestureDetector mGestureDetector;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 步骤1:创建手势检测器实例 & 传入OnGestureListener接口(需要复写对应方法)mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {// OnGestureListener接口的函数// 1. 用户轻触触摸屏public boolean onDown(MotionEvent e) {Log.i("MyGesture1", "onDown");return false;}// 2. 用户轻触触摸屏,尚未松开或拖动// 与onDown()的区别:无松开 / 拖动// 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行public void onShowPress(MotionEvent e) {Log.i("MyGesture", "onShowPress");}// 3. 用户长按触摸屏public void onLongPress(MotionEvent e) {Log.i("MyGesture", "onLongPress");}// 4. 用户轻击屏幕后抬起public boolean onSingleTapUp(MotionEvent e) {Log.i("MyGesture", "onSingleTapUp");return true;}// 5. 用户按下触摸屏 & 拖动public boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {Log.i("MyGesture", "onScroll:");return true;}// 6. 用户按下触摸屏、快速移动后松开// 参数:// e1:第1个ACTION_DOWN MotionEvent// e2:最后一个ACTION_MOVE MotionEvent// velocityX:X轴上的移动速度,像素/秒// velocityY:Y轴上的移动速度,像素/秒public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {Log.i("MyGesture", "onFling");return true;}// OnDoubleTapListener的函数// 1. 单击事件// 关于OnDoubleTapListener.onSingleTapConfirmed()和 OnGestureListener.onSingleTapUp()的区别// onSingleTapConfirmed:再次点击(即双击),则不会执行// onSingleTapUp:手抬起就会执行public boolean onSingleTapConfirmed(MotionEvent e) {Log.i("MyGesture", "onSingleTapConfirmed");return false;}// 2. 双击事件public boolean onDoubleTap(MotionEvent e) {Log.i("MyGesture", "onDoubleTap");return false;}// 3. 双击间隔中发生的动作// 指触发onDoubleTap后,在双击之间发生的其它动作,包含down、up和move事件;public boolean onDoubleTapEvent(MotionEvent e) {Log.i("MyGesture", "onDoubleTapEvent");return false;}});// 步骤2:重写View的onTouch函数,将触屏事件交给GestureDetector处理,从而对用户手势作出响应mTextView = (TextView) findViewById(R.id.textView);mTextView.setOnTouchListener(new View.OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {mGestureDetector.onTouchEvent(event);return true;}});}
}

5. 测试效果

日志效果如下

至此,关于Android手势识别类GestureDetector类使用讲解完毕。


总结

  • 本文主要对Android手势识别类:GestureDetector类的使用进行全面讲解
  • Carson带你学Android系列文章
    Carson带你学Android:学习方法
    Carson带你学Android:四大组件
    Carson带你学Android:自定义View
    Carson带你学Android:异步-多线程
    Carson带你学Android:性能优化
    Carson带你学Android:动画

欢迎关注Carson_Ho的CSDN博客 与 公众号!

博客链接:https://carsonho.blog.csdn.net/


请帮顶 / 评论点赞!因为你的鼓励是我写作的最大动力!

这篇关于Carson带你学Android:手把手教你学会手势识别应用 GestureDetector的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/214287

相关文章

利用Python操作Word文档页码的实际应用

《利用Python操作Word文档页码的实际应用》在撰写长篇文档时,经常需要将文档分成多个节,每个节都需要单独的页码,下面:本文主要介绍利用Python操作Word文档页码的相关资料,文中通过代码... 目录需求:文档详情:要求:该程序的功能是:总结需求:一次性处理24个文档的页码。文档详情:1、每个

Java中的分布式系统开发基于 Zookeeper 与 Dubbo 的应用案例解析

《Java中的分布式系统开发基于Zookeeper与Dubbo的应用案例解析》本文将通过实际案例,带你走进基于Zookeeper与Dubbo的分布式系统开发,本文通过实例代码给大家介绍的非常详... 目录Java 中的分布式系统开发基于 Zookeeper 与 Dubbo 的应用案例一、分布式系统中的挑战二

Java 缓存框架 Caffeine 应用场景解析

《Java缓存框架Caffeine应用场景解析》文章介绍Caffeine作为高性能Java本地缓存框架,基于W-TinyLFU算法,支持异步加载、灵活过期策略、内存安全机制及统计监控,重点解析其... 目录一、Caffeine 简介1. 框架概述1.1 Caffeine的核心优势二、Caffeine 基础2

使用Node.js和PostgreSQL构建数据库应用

《使用Node.js和PostgreSQL构建数据库应用》PostgreSQL是一个功能强大的开源关系型数据库,而Node.js是构建高效网络应用的理想平台,结合这两个技术,我们可以创建出色的数据驱动... 目录初始化项目与安装依赖建立数据库连接执行CRUD操作查询数据插入数据更新数据删除数据完整示例与最佳

如何正确识别一台POE交换机的好坏? 选购可靠的POE交换机注意事项

《如何正确识别一台POE交换机的好坏?选购可靠的POE交换机注意事项》POE技术已经历多年发展,广泛应用于安防监控和无线覆盖等领域,需求量大,但质量参差不齐,市场上POE交换机的品牌繁多,如何正确识... 目录生产标识1. 必须包含的信息2. 劣质设备的常见问题供电标准1. 正规的 POE 标准2. 劣质设

Android实现图片浏览功能的示例详解(附带源码)

《Android实现图片浏览功能的示例详解(附带源码)》在许多应用中,都需要展示图片并支持用户进行浏览,本文主要为大家介绍了如何通过Android实现图片浏览功能,感兴趣的小伙伴可以跟随小编一起学习一... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

在Android中使用WebView在线查看PDF文件的方法示例

《在Android中使用WebView在线查看PDF文件的方法示例》在Android应用开发中,有时我们需要在客户端展示PDF文件,以便用户可以阅读或交互,:本文主要介绍在Android中使用We... 目录简介:1. WebView组件介绍2. 在androidManifest.XML中添加Interne

PHP应用中处理限流和API节流的最佳实践

《PHP应用中处理限流和API节流的最佳实践》限流和API节流对于确保Web应用程序的可靠性、安全性和可扩展性至关重要,本文将详细介绍PHP应用中处理限流和API节流的最佳实践,下面就来和小编一起学习... 目录限流的重要性在 php 中实施限流的最佳实践使用集中式存储进行状态管理(如 Redis)采用滑动

深入浅出Spring中的@Autowired自动注入的工作原理及实践应用

《深入浅出Spring中的@Autowired自动注入的工作原理及实践应用》在Spring框架的学习旅程中,@Autowired无疑是一个高频出现却又让初学者头疼的注解,它看似简单,却蕴含着Sprin... 目录深入浅出Spring中的@Autowired:自动注入的奥秘什么是依赖注入?@Autowired

Android协程高级用法大全

《Android协程高级用法大全》这篇文章给大家介绍Android协程高级用法大全,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友跟随小编一起学习吧... 目录1️⃣ 协程作用域(CoroutineScope)与生命周期绑定Activity/Fragment 中手