我正在尝试创建一个自定义对话框。当我调用该setOnClickListner
方法时,我得到一个“类型视图中的方法 setOnClickListner 不适用于参数”。我也收到一条错误消息:
public void onClick(View v)
说“新的 OnClickListener(){} 类型的方法 onClick(View) 必须覆盖或实现超类型方法”。代码:
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();
}