https://github.com/dora4/dora_empty_layout
空数据、空态布局控件
https://github.com/dora4/dora_empty_layout
Last synced: 10 months ago
JSON representation
空数据、空态布局控件
- Host: GitHub
- URL: https://github.com/dora4/dora_empty_layout
- Owner: dora4
- Created: 2021-10-09T17:08:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-10T06:38:41.000Z (over 4 years ago)
- Last Synced: 2025-06-30T03:05:56.952Z (12 months ago)
- Language: Kotlin
- Homepage:
- Size: 3.56 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DoraEmptyLayout
描述:一个用来显示暂无数据、加载中和加载错误的布局容器
复杂度:★★☆☆☆
分组:【Dora大控件组】
关系:暂无
技术要点:自定义属性、向ViewGroup中添加控件
### 照片

### 动图

### 软件包
https://github.com/dora4/dora_empty_layout/blob/main/art/dora_empty_layout.apk
### 用法
它只能有且只有一个子控件,这个唯一的子控件作为content。通过调用showEmpty、showError、showLoading、showContent来改变显示,在onEmpty、onError、onLoading、onRefresh中处理回调。
```kotlin
emptyLayout = findViewById(R.id.emptyLayout)
emptyLayout
.onEmpty {
Toast.makeText(this@MainActivity, "onEmpty", Toast.LENGTH_SHORT).show()
}
.onError { e ->
val tvError = findViewById(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 | 配置加载中的布局 |