我有一个回收商从改造中接收信息。我希望进度条一直处于 Activity 状态,直到完成此信息的处理。 (可能是进度条可见的时间或其他)
我使用自定义进度条 - https://github.com/ybq/Android-SpinKit
public void retrofitView() {
ProgressBar progressBar;
progressBar = findViewById(R.id.ProgressBar_MainActivity);
DoubleBounce doubleBounce = new DoubleBounce();
progressBar.setIndeterminateDrawable(doubleBounce);
progressBar.setVisibility(View.VISIBLE);
Call<List<Restaurants>> call = RetrofitClient.apiService.getRestaurants();
call.enqueue(new Callback<List<Restaurants>>() {
@Override
public void onResponse(Call<List<Restaurants>> call, Response<List<Restaurants>> response) {
restaurantRecyclerInit(response.body());
}
@Override
public void onFailure(Call<List<Restaurants>> call, Throwable t) {
Toast.makeText(MainActivity.this, "ddd", Toast.LENGTH_SHORT).show();
}
});
}
最佳答案
只需在 onResponse
和 onFailure
中设置 progressBar.setVisibility(View.GONE);
。
不要设置计时器,因为您不知道它会持续多长时间。
关于java - 在完整内容处理之前设置 ProgressBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56057773/