之前全部内容处理设置进度

loveubae:

我有谁从改造接收信息的回收。我希望进度条被激活,直到该信息的完整处理。(可能是进度条或其他什么东西的可见性的时间)

我用一个自定义的进度- 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();
        }
    });
}
阿希什:

使用下面的代码将帮助你

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) {
            progressBar.setVisibility(View.GONE); //This will make your progress bar visibility off after data load successfully
            restaurantRecyclerInit(response.body());
        }

        @Override
        public void onFailure(Call<List<Restaurants>> call, Throwable t) {
            progressBar.setVisibility(View.GONE); // Same here also
            Toast.makeText(MainActivity.this, "ddd", Toast.LENGTH_SHORT).show();
        }
    });
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章