DoraEmptyLayout
描述:一个用来显现暂无数据、加载中和加载错误的布局容器
复杂度:★★☆☆☆
分组:【Dora大控件组】
联系:暂无
技能要点:自定义特点、向ViewGroup中增加控件
照片




动图

软件包
github.com/dora4/dora_…
用法
它只能有且只有一个子控件,这个唯一的子控件作为content。经过调用showEmpty、showError、showLoading、showContent来改动显现,在onEmpty、onError、onLoading、onRefresh中处理回调。
emptyLayout = findViewById(R.id.emptyLayout)
emptyLayout
.onEmpty {
Toast.makeText(this@MainActivity, "onEmpty", Toast.LENGTH_SHORT).show()
}
.onError { e ->
val tvError = findViewById<TextView>(R.id.tvError)
tvError.text = e.message
Toast.makeText(this@MainActivity, "onError", Toast.LENGTH_SHORT).show()
}
.onLoading {
((this as ImageView).drawable as AnimationDrawable).start()
Toast.makeText(this@MainActivity, "onLoading", Toast.LENGTH_SHORT).show()
}
.onRefresh {
Toast.makeText(this@MainActivity, "onRefresh", Toast.LENGTH_SHORT).show()
}
自定义特点 | 描述 |
---|---|
dora_emptyLayout | 装备空数据的布局 |
dora_errorLayout | 装备加载错误的布局 |
dora_loadingLayout | 装备加载中的布局 |
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。