听主屏幕的android触摸事件 [英] listen to android touch events of home screen

查看:62
本文介绍了听主屏幕的android触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在开发一个应用程序,我想知道用户在Android手机的主屏幕上向下或向上滑动。基本上我想在用户在主屏幕上向上/向下滑动时执行一些操作。



我在网上搜索了很多但是没有找到答案是否可能或不。如果有可能,那么我可以从那里学习如何做到这一点。



预先感谢您的回复。*

Hello everyone,

I am developing an app in which I want to know when user swipe down or up on the home screen of the android mobile. Basically I want to perform some action whenever user swipe up/down on the home screen.

I search a lot on the web but found no answer whether it is possible or not. If it is possible then from where I can learn how to do this.

Thanks in advance for your kind reply.*

推荐答案

你需要覆盖 onTouchEvent()

You need to override onTouchEvent():
@Override
public void onTouchEvent(MotionEvent event) {

     switch(event.getAction())
     {
        case MotionEvent.ACTION_DOWN:
         //do your stuff
         break;
        case MotionEvent.ACTION_UP:
         //do your stuff
         break;
     }
}


这篇关于听主屏幕的android触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆