对于想了解android–onTouch事件有时不会触发ACTION_POINTER_DOWN的读者,本文将提供新的信息,我们将详细介绍androidontouchontouchevent,并且为您提
对于想了解android – onTouch事件有时不会触发ACTION_POINTER_DOWN的读者,本文将提供新的信息,我们将详细介绍android ontouch ontouchevent,并且为您提供关于Android 0nTouch事件问题[向下轻扫]、Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI、Android GridView中点击图片为何只能捕获ACTION_DOWN事件,其他事件未触发?、Android Intent.ACTION_SCREEN_OFF和Intent.ACTION_USER_PRESENT如何注册的有价值信息。
本文目录一览:- android – onTouch事件有时不会触发ACTION_POINTER_DOWN(android ontouch ontouchevent)
- Android 0nTouch事件问题[向下轻扫]
- Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI
- Android GridView中点击图片为何只能捕获ACTION_DOWN事件,其他事件未触发?
- Android Intent.ACTION_SCREEN_OFF和Intent.ACTION_USER_PRESENT如何注册
android – onTouch事件有时不会触发ACTION_POINTER_DOWN(android ontouch ontouchevent)
解决方法
switch(event.getAction() & MotionEvent.ACTION_MASK){ case MotionEvent.ACTION_DOWN: some code break; case MotionEvent.ACTION_POINTER_DOWN: ETC
Android 0nTouch事件问题[向下轻扫]
我有一个需要onTouch滑动事件的应用程序,如在Iphone中.他们是
>向上滑动.
>向下滑动.
>向左滑动.
>向右滑动.
我实现了onTouch事件如下.我正确地向左和向右滑动.但这是实现向下滑动和向上滑动操作的正确方法.
mycode的:
float downXValue,downYValue;
@Override
public boolean onTouchEvent(MotionEvent arg1) {
// Get the action that was done on this touch event
switch (arg1.getAction())
{
case MotionEvent.ACTION_DOWN:
{
// store the X value when the user's finger was pressed down
downXValue = arg1.getX();
downYValue = arg1.getY();
break;
}
case MotionEvent.ACTION_UP:
{
// Get the X value when the user released his/her finger
float currentX = arg1.getX();
float currentY=arg1.getY();
// going backwards: pushing stuff to the right
if (downXValue < currentX)
{
Log.d(DEBUG_TAG, "Right");
}
// going forwards: pushing stuff to the left
if (downXValue > currentX)
{
Log.d(DEBUG_TAG, "Left");
}
break;
}
}
//GestureListener is called here...
//return gestures.onTouchEvent(event);
return true;
}
谢谢.
解决方法:
关于什么…
if (downYValue < currentY)
{
Log.d(DEBUG_TAG, "Down");
}
你确定你写了上面的代码吗?
编辑
好的,我相信你.你要做的基本上是:
double sizeInX = Math.abs(downXValue - currentX);
double sizeInY = Math.abs(downYValue - currentY);
if( sizeInX > sizeInY ){
// you better swipe horizontally
} else {
// you better swipe vertically
}
Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI
在 KitKat 之前(或在新画廊之前)Intent.ACTION_GET_CONTENT
返回一个这样的 URI
内容://媒体/外部/图像/媒体/3951。
使用ContentResolver
和查询 MediaStore.Images.Media.DATA
返回的文件 URL。
然而,在 KitKat 中,Gallery 会返回一个 URI(通过“Last”),如下所示:
内容://com.android.providers.media.documents/document/image:3951
我该如何处理?
Android GridView中点击图片为何只能捕获ACTION_DOWN事件,其他事件未触发?
在GridView中设置一张图片,鼠标点击这张图片时为何只能捕获ACTION_DOWN事件,其他事件没有反应,是不是哪被拦截了?
有没有知道的兄弟?讲解一下。
部分代码:
SimpleAdapter sadapter = new SimpleAdapter(this, listmap, R.layout.griditem, new String[]{"icon"}, new int[]{R.id.imageview});
gview.setAdapter(sadapter);
sadapter.setViewBinder(new ViewBinder(){
public boolean setViewValue(View view, Object data,
String textRepresentation) {
if((view instanceof ImageView) && (data instanceof Integer)){
ImageView imageview = (ImageView)view;
int iconid = (Integer)data;
imageview.setBackgroundResource(iconid);
imageview.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent event) {
Log.d("debug", "action["+event.getAction()+"]");
return false;
}});
return true;
}
return false;
}});
后台日志打印:
08-14 05:24:27.293: D/debug(2359): action[0]
只能打印出值为0的动作(也就是ACTION_DOWN),无其他动作值。
Android Intent.ACTION_SCREEN_OFF和Intent.ACTION_USER_PRESENT如何注册
Activity has leaked IntentReceiver ScreenReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?
在我的主要活动中
// Register receiver that handles screen on and screen off logic
final IntentFilter intentScreenfilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
intentScreenfilter.addAction(Intent.ACTION_SCREEN_OFF);
intentScreenfilter.addAction(Intent.ACTION_USER_PRESENT);
screenReceiver = new ScreenReceiver();
当应用程序关闭时,我收到此消息.
ACTION_SCREEN_OFF
和
ACTION_SCREEN_ON
无法在AndroidManifest中注册,只能以编程方式注册.我能做什么?我不想使用服务,因为如果服务全天运行,这对电池不利.解决办法是什么?如何使用这个接收器?
解决方法:
你不能从android清单文件注册这些接收器.它根本不支持.唯一的方法是长时间运行服务并在服务中注册这些接收器.所以,如果你真的想使用
ACTION_SCREEN_ON
和
ACTION_SCREEN_OFF
然后你必须使用服务
关于android – onTouch事件有时不会触发ACTION_POINTER_DOWN和android ontouch ontouchevent的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Android 0nTouch事件问题[向下轻扫]、Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI、Android GridView中点击图片为何只能捕获ACTION_DOWN事件,其他事件未触发?、Android Intent.ACTION_SCREEN_OFF和Intent.ACTION_USER_PRESENT如何注册的相关信息,请在本站寻找。
本文标签: