我試圖做一個客戶對話框,但我收到錯誤時,我打電話OnClickListener
和它通過OnClickListener()
類作爲參數。該錯誤是試圖設置一個按鈕的OnClickListner
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new OnClickListener(){})
也是它說的錯誤消息類型來看,它不應該是Button
,會是這樣的問題?
代碼
// error message on line below
Button dialogButton = (Button) dialog.findViewById(R.id.action_settings);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
你能證明你的進口 – Raghunandan
我要猜你使用的錯誤的'進口' –