指定view.onclicklistener,只是有onclicklistener之间的区别 [英] Difference between specifying the view.onclicklistener and just having onclicklistener

查看:233
本文介绍了指定view.onclicklistener,只是有onclicklistener之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看着 http://developer.android.com/reference /android/view/package-summary.html
只见该视图类有一个名为View.OnClickListener的界面,这是一个回调接口定义在单击视图时要调用我的问题是有什么区别,如果你指定视图或没有在界面?

I looked on http://developer.android.com/reference/android/view/package-summary.html and saw that the view class has an interface named "View.OnClickListener" which is "Interface definition for a callback to be invoked when a view is clicked" My question is what the difference is if you specify the view or not in the interface?

基本上是

button.setOnClickListener(新Button.OnClickListener()
一样的

button.setOnClickListener(new Button.OnClickListener() the Same as

button.setOnClickListener(新OnClickListener()?

button.setOnClickListener(new OnClickListener()?

推荐答案

有中 setOnClickListener 一为查看类和一个参考 DialogInterface 类。

There are 2 of setOnClickListener one for the View class and one refer to DialogInterface Class.

所以要以操纵视图像按钮的ImageView 并添加一个动作,你需要使用 View.OnClickListener 在处理你应该使用对话框按钮 DialogIneterface.onClickListener 都有不同的参数。

So to in order to manipulate the View like a Button or ImageView and add an action to it, you need to use View.OnClickListener while dealing with Dialog buttons you should use DialogIneterface.onClickListener both have different arguments.

通常加入 onClickListener ,视图类将被默认进口或它会让你两个类之间进行选择。这样你就不需要添加 View.onClickListener 。但是,如果类 DialogInterface 已经被导入,您要使用的视图onClickListener那么你必须写 View.onClickListener 区分这两个类 onClickListener

Usually by adding onClickListener, the View Class will be imported by default or it will make you choose between both classes. so you don't need to add View.onClickListener. However, if the class DialogInterface have been imported already and you want to use the View onClickListener then you have to write View.onClickListener to differentiate both classes' onClickListener.

希望这是现在很清楚,这是你在找什么。

Hope it is clear now and this is what you are looking for.

这篇关于指定view.onclicklistener,只是有onclicklistener之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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