From 03980a86b431b6a3f0103500c30b941f6d5a2890 Mon Sep 17 00:00:00 2001 From: "16167479@qq.com" <16167479@qq.com> Date: Fri, 13 May 2022 15:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A9=BA=E6=96=87=E5=AD=97?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E7=BD=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/lxj/demo1/MainActivity.kt | 2 +- .../src/main/java/com/lxj/statelayout/StateLayout.kt | 4 ++-- .../src/main/java/com/lxj/statelayout/StateLayoutConfig.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/lxj/demo1/MainActivity.kt b/app/src/main/java/com/lxj/demo1/MainActivity.kt index 5ef64e8..9fbc6ec 100644 --- a/app/src/main/java/com/lxj/demo1/MainActivity.kt +++ b/app/src/main/java/com/lxj/demo1/MainActivity.kt @@ -106,7 +106,7 @@ class MainActivity : AppCompatActivity() { emptyIcon = R.mipmap.ic_launcher_round, loadingLayoutId = R.layout.custom_loading2, errorLayoutId = R.layout.custom_error, - emptyLayoutId = R.layout.custom_empty +// emptyLayoutId = R.layout.custom_empty ) { slInLayout.postDelayed({slInLayout.showEmpty()}, 1000) } slInLayout.showLoading() slInLayout.postDelayed({slInLayout.showContent()}, 2000) diff --git a/statelayout-library/src/main/java/com/lxj/statelayout/StateLayout.kt b/statelayout-library/src/main/java/com/lxj/statelayout/StateLayout.kt index ba9fc8c..52d142b 100644 --- a/statelayout-library/src/main/java/com/lxj/statelayout/StateLayout.kt +++ b/statelayout-library/src/main/java/com/lxj/statelayout/StateLayout.kt @@ -262,9 +262,9 @@ class StateLayout @JvmOverloads constructor(context: Context, attributeSet: Attr val group = emptyView as ViewGroup (0 until group.childCount).forEach { val child = group.getChildAt(it) - if(child is TextView && child.text.isNullOrEmpty() && !emptyText.isNullOrEmpty()) { + if(child is TextView && !emptyText.isNullOrEmpty()) { child.text = emptyText - }else if(child is ImageView && child.drawable==null && emptyIcon!=0){ + }else if(child is ImageView && emptyIcon!=0){ child.setImageResource(emptyIcon) } } diff --git a/statelayout-library/src/main/java/com/lxj/statelayout/StateLayoutConfig.kt b/statelayout-library/src/main/java/com/lxj/statelayout/StateLayoutConfig.kt index b822d15..4a6ba1e 100644 --- a/statelayout-library/src/main/java/com/lxj/statelayout/StateLayoutConfig.kt +++ b/statelayout-library/src/main/java/com/lxj/statelayout/StateLayoutConfig.kt @@ -7,7 +7,7 @@ object StateLayoutConfig { var animDuration = 120L var useContentBgWhenLoading = false //是否在Loading状态使用内容View的背景 var enableLoadingShadow = false //是否启用加载状态时的半透明阴影 - var emptyText: String = "暂无数据" + var emptyText: String = "" var emptyIcon: Int = 0 var enableTouchWhenLoading = false var defaultShowLoading = false