完全なコンテンツ処理前のセットのProgressBar

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();
        }
    });
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=205014&siteId=1
おすすめ