github:https://github.com/orhanobut/dialogplus
github原圖:
demo效果圖:
總有3個Holder:ViewHolder、ListHolder、GridHolder,其中ViewHolder
是用于自定義視圖,ListHolder
用于ListView
,GridHolder
用于GridView
。
方法 | 說明 |
---|---|
newDialog(Context context) | 創建dialog |
setContentHolder(Holder holder) | 設置holder,必要 |
setContentWidth(int width) | 寬:ViewGroup.LayoutParams.WRAP_CONTENT等 |
setContentHeight(int height) | 高 |
setHeader(int resourceId) | 頭的布局或View |
setFooter(int resourceId) | 尾的布局或View |
setGravity(int gravity) | dialog的位置 |
setExpanded(boolean expanded) | 是否可擴展,默認是false,僅適用于ListView和GridView |
setCancelable(boolean isCancelable) | 點擊外部區域是否可以取消dialog |
setAdapter(BaseAdapter adapter) | ListView或GridView的adapter,ViewHolder不需要 |
setOnItemClickListener(OnItemClickListener listener) | ListView或GridView的item的點擊事件 |
setOnClickListener(OnClickListener listener) | 點擊事件 |
setOnDismissListener(OnDismissListener listener) | dismiss的監聽 |
setOnCancelListener(OnCancelListener listener) | 取消的監聽 |
getHolderView() | 獲取視圖View |
getHeaderView() | 獲取頭布局 |
getFooterView() | 獲取尾布局 |
setMargin(left, top, right, bottom) | Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins are applied |
setPadding(left, top, right, bottom) | Set padding to the holder |
setInAnimation(R.anim.abc_fade_in) | 進入動畫 |
setOutAnimation(R.anim.abc_fade_out) | 移除動畫 |
setContentBackgroundResource(resource) | dialog的背景色 |
setOverlayBackgroundResource(resource) | dialog意外的背景色 |
https://git.oschina.net/libraryDemo/DialogPlus01
github地址:https://github.com/pedant/sweet-alert-dialog
注意:直接這樣添加依賴會報錯:
解決方法:
在AndroidManifest.xml中添加xmlns:tools="http://schemas.android.com/tools"tools:replace="android:icon"點擊確認后切換到對話框樣式:
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog .setTitleText("Deleted!") .setContentText("Your imaginary file has been deleted!") .setConfirmText("OK") .setConfirmClickListener(null) .changeAlertType(SweetAlertDialog.SUCCESS_TYPE); }})https://git.oschina.net/libraryDemo/SweetAlertDialog01
|
新聞熱點
疑難解答