的OnClick()事件和OnClickListener之间的区别?区别、事件、OnClick、OnClickListener

由网友(断情)分享简介:我总是在我的大部分项目中使用的onclick()事件。但是,我读 OnClickListener()。谁能告诉什么是这两者之间的区别是什么?哪一个是最好的Andr​​oid应用程序中使用? I'm always using onclick() event in most of my projects. But, I...

我总是在我的大部分项目中使用的onclick()事件。但是,我读 OnClickListener()。谁能告诉什么是这两者之间的区别是什么?哪一个是最好的Andr​​oid应用程序中使用?

I'm always using onclick() event in most of my projects. But, I read about OnClickListener(). Can anyone tell what's the difference between these two? And which one is best to use in Android application?.

推荐答案

我不知道这个问题是显而易见的。 View.OnClickListener 是一个接口,它定义了的onClick(视图)方法。如果你有一个类,它打算监听点击,你都应该实现的接口(如果尚未扩展一个类,做),并实施这种方法了。你必须同时使用;他们不是在某种程度上替代品。

I'm not sure the question is clear. View.OnClickListener is an interface, which defines the onClick(View) method. If you have a class which intends to listen for clicks, you should both implement the interface (if not already extending a class that does), and implement this method too. You have to use both; they're not somehow alternatives.

阅读全文

相关推荐

最新文章