The Method SetOnClickListener(View.OnClickListener) In The Type View Is Not Applicable For The Arguments (new DialogInterface.OnClickListener(){})
Attempting to add an onClickListener to items in my listView and I'm getting an error stating: 'The method setOnClickListener(View.OnClickListener) in the type View is not applicab
Solution 1:
you probably have the wrong import. Check if you imported DialogInterface.OnClickListener. Still you can explicitly force the parameter this way:
holder.imageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(context, "Clicked on image",
Toast.LENGTH_LONG).show();
}
Solution 2:
use View.OnClickListener instead of OnClickListener :
holder.imageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(context, "Clicked on image",
Toast.LENGTH_LONG).show();
}
and use CTL+SHIFT+O to fix all imports
Post a Comment for "The Method SetOnClickListener(View.OnClickListener) In The Type View Is Not Applicable For The Arguments (new DialogInterface.OnClickListener(){})"