【发布时间】:2019-08-24 14:46:32
【问题描述】:
在收到服务器响应后,我正在尝试停止进度条。 下面是我用过的xml代码
activity.xml
<ProgressBar
android:layout_weight="1"
android:id="@+id/progressBar"
android:indeterminate="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:minWidth="40dp"
tools:ignore="MissingConstraints" />
activity.kt
var progressBar = findViewById(R.id.progressBar) as ProgressBar
doAsync {
try {
progressBar.setVisibility(View.VISIBLE);
appList = getAppList(requestBody, LAUNCHER_BASE_URL)
Log.d("App list =", appList.toString())
appInfoList = populateList()
progressBar.setVisibility(View.GONE);
} catch (e: Exception) {
progressBar.setVisibility(View.GONE);
Log.e("Exception-launcher", e.toString())
}
从上面的代码来看,即使收到响应,进度条也不会停止。任何帮助将不胜感激
我试过了,但是进度条停止后页面变成空白
【问题讨论】:
-
因为你的进度条消失了,而它抛出了一些异常,而不是你获得成功响应的时候。
-
所以你想在进度条停止后向用户显示响应?并且您的显示在进度条消失后变为空白。这意味着您没有将您的回复附加到您的设计中。
标签: android kotlin progress-bar