OnTouch和安卓的OnClick区别 [英] difference between OnTouch and OnClick Android

查看:148
本文介绍了OnTouch和安卓的OnClick区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问有没有从编程的角度但从用户体验角度,

在OnTouchListner和OnClickListner任何区别

哪一个是更好地使用?

我们需要同时实现?

解决方案
  

哪一个是更好地使用?

这真的取决于你的需求。 onTouch为您提供了运动事件。因此,你可以做很多花哨的东西,因为它帮助你运动的不同状态。仅举几

  • ACTION_UP
  • ACTION_DOWN
  • ACTION_MOVE

这些都是我们平时实施得到渴望的结果共同行动,如拖在屏幕上查看。

在另一方面,的onClick不会给你太多,除了它查看用户交互。的onClick是一个完整的事件,包括聚焦,pressing和释放。所以,你无法控制它。一边起来是很容易实现。

  

我们需要同时实现?

除非你想搞砸你的用户是没有必要的。如果你只是想简单的单击事件,去的onClick。如果你想比一下,去onTouch。这样做既会过程复杂化。

但从用户的角度,如果您实现onTouch认真的样子的onClick是不明显的。

Is there any difference in OnTouchListner and OnClickListner not from the programming point of view but from the User Experience point of view,

which one is better to use?

do we need to implement both?

解决方案

which one is better to use?

It really depends on your requirement. onTouch gives you Motion Event. Thus, you can do a lot of fancy things as it help you separate state of movement. Just to name a few

  • ACTION_UP
  • ACTION_DOWN
  • ACTION_MOVE

Those are common actions we usually implement to get desire result such as dragging view on screen.

On the other hand, onClick doesn't give you much except which view user interacts. onClick is a complete event comprising of focusing,pressing and releasing. So, you have little control over it. One side up is it is very simple to implement.

do we need to implement both?

It is not necessary unless you want to mess up with your user. If you just want simple click event, go for onClick. If you want more than click, go for onTouch. Doing both will complicate the process.

From User point of view, it is unnoticeable if you implement onTouch carefully to look like onClick.

这篇关于OnTouch和安卓的OnClick区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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