AlertDialog的簡要說明

AlertDialog是Android中最常用的對話框之一,但不能直接通過AlertDialog的構造函數來產生一個AlertDialog。需通過AlertDialog.Builder創建,

AlertDialog.Builder alertDialog  =new  AlertDialog.Builder(this).create(); 

常用到的方法如下:

create ( ): 對話框創建

show ( ):對話框顯示

setTitle ( ):爲對話框設置標題
setIcon( ):爲對話框設置圖標
setMessage ( ):爲對話框設置要顯示的內容

setView ( ): 爲對話框設置樣式
setItems ( ):爲對話框添加列表項

setSingleChoiceItems ( ):爲對話框添加單選列表項

setMultiChoiceItems ( ):爲對話框添加多選列表項

setNeutralButton ( ):爲對話框添加中立按鈕

setPositiveButton ( ):爲對話框添加確定按鈕
setNegativeButton ( ):爲對話框添加取消按鈕

setCanceledOnTouchOutside (true):點擊對話框外部取消對話框顯示(默認爲true)

setCancelable (true):按返回鍵取消對話框顯示(默認爲true)



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章