Skip to content

clicked list dialog API for Kotlin

vincent(朱志强) edited this page Sep 15, 2023 · 9 revisions

回到API首页

效果图

目录导航

快速上手

创建并显示dialog

回到目录导航

SmartDialog.builderOfClickedList()
    .items(listOf("回复", "转发", "私信回复", "复制", "举报"))
    .itemClickedListener { dialog, clickedItem ->
        dialog.dismiss()
        SmartToast.classic().showInCenter(clickedItem.value)
    }
    .build(activity)
    .show()

复用dialog

回到目录导航

val handle = SmartDialog.builderOfClickedList()
    .items(listOf("回复", "转发", "私信回复", "复制", "举报"))
    .itemClickedListener { dialog, clickedItem ->
        dialog.dismiss()
        SmartToast.classic().showInCenter(clickedItem.value)
    }
    .build(activity)
//显示
handle.show()
//隐藏
handle.dismiss()
//是否正在显示
handle.isShowing()

详细API

设置title

回到目录导航

SmartDialog.builderOfClickedList()
.title("title")
.build(activity)
.show()

或者,

SmartDialog.builderOfClickedList()
.titleResource(R.string.clicked_list_title)
.build(activity)
.show()

设置title的文本风格

回到目录导航

SmartDialog.builderOfClickedList()
    //颜色,大小(单位sp),是否加粗
    .titleStyle(Color.BLUE,18f,false)
    .build(activity)
    .show()

设置列表项

回到目录导航

SmartDialog.builderOfClickedList()
    .items(listOf("回复", "转发", "私信回复", "复制", "举报"))
    .build(activity)
    .show()

或者,

SmartDialog.builderOfClickedList()
    .itemsResource(R.array.clicked_list_items)
    .build(activity)
    .show()

设置列表项的文本风格

回到目录导航

SmartDialog.builderOfClickedList()
    //颜色,大小(sp),是否加粗
    .itemStyle(Color.parseColor("#333333"), 14f, false)
    .build(activity)
    .show()

设置列表项点击监听器

回到目录导航

SmartDialog.builderOfClickedList()
    .itemClickedListener { dialog, clickedItem ->
        dialog.dismiss()
        //do something with clickedItem
    }
    .build(activity)
    .show()

设置是否dim(显示时周围背景是否变暗)

回到目录导航

SmartDialog.builderOfClickedList()
//默认为true,也就是常见的配置,dialog显示时,周围背景是灰色蒙层
.dimBehind(true)
.build(activity)
.show()

设置是否可通过BACK键取消

回到目录导航

SmartDialog.builderOfClickedList()
//默认为true
.cancelable(true)
.build(activity)
.show()

设置是否可通过触碰周边区域取消dialog

回到目录导航

SmartDialog.builderOfClickedList()
//默认false
.cancelOnTouchOutside(false)
.build(activity)
.show()

dialog显示监听器

回到目录导航

SmartDialog.builderOfClickedList()
    .dialogShowListener {
        //do something
    }
    .build(activity)
    .show()

dialog隐藏监听器

回到目录导航

SmartDialog.builderOfClickedList()
    .dialogDismissListener {
        //do something
    }
    .build(activity)
    .show()

dialog取消监听器

回到目录导航

SmartDialog.builderOfClickedList()
    .dialogCancelListener {
        //do something
    }
    .build(activity)
    .show()

1

Clone this wiki locally