Reputation: 9261
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?
Basically is
button.setOnClickListener(new Button.OnClickListener() the Same as
button.setOnClickListener(new OnClickListener()?
Upvotes: 1
Views: 1296
Reputation: 7745
There are 2 of setOnClickListener
one for the View
class and one refer to DialogInterface
Class.
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.
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.
Upvotes: 4