The method setButton(int, CharSequence, Message) in the type AlertDialog is not applicable for the a
生活随笔
收集整理的這篇文章主要介紹了
The method setButton(int, CharSequence, Message) in the type AlertDialog is not applicable for the a
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
用dialog做彈出框的時候,報錯,如下圖
感覺很奇怪,報的錯誤,我寫在標(biāo)題了,,解決方法,在OnClickListener前添加DialogInterface
例如取消,, alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
finish();
}
});
? ? ?為什么這么改,
實(shí)際上就是一個錯誤,AlertDialog.setButton()里,第三個參數(shù)是一個OnClickListener,這個監(jiān)聽器類是DialogInterface里的,看異常說明,你那導(dǎo)入的類應(yīng)該是View類里的OnClickListener。所以會出現(xiàn)類型異常。
這是我百度的,別人的回答。
總結(jié)
以上是生活随笔為你收集整理的The method setButton(int, CharSequence, Message) in the type AlertDialog is not applicable for the a的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DocumentsContract ca
- 下一篇: GridView使用的技巧