I’m trying to create a custom dialog. When I call the setOnClickListner method I get a
“the method setOnClickListner in the type view is not applicable for arguments.” I also get a error on the line:
public void onClick(View v)
saying “The method onClick(View) of type new OnClickListener(){} must override or implement a supertype method”. Code:
void ReStartsFamilyFriend()
{
// custom dialog
// custom dialog
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.gameover);
dialog.setTitle("Title...");
// set the custom dialog components - text, image and button
Button dialogButton = (Button) dialog.findViewById(R.id.butPlay);
// if button is clicked, close the custom dialog
//on this line below get the error "The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments "
dialogButton.setOnClickListener(new OnClickListener() {
@Override
/*On the line below I get the error
"The method onClick(View) of type new OnClickListener(){} must override or implement a supertype
method"*/
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
I feel like what you are trying to do is simply dismiss an alert using a different button other than one on the alert dialog. Your best option would be to use VVVVVVVVVVVVVVVVVv
Theres no need to put a button in the view if you use an alertDialog.builder.
Check out the link here