小编Ome*_*ish的帖子

Retrofit 2 - 如何在接收JSON响应时显示进度条

我在选项卡式活动中使用多个片段来显示json数据.
我想在每个片段收到响应时显示进度条.

private void loadJSON() {
  Retrofit retrofit = new Retrofit.Builder()
                                  .baseUrl(BASEURL)
                                  .addConverterFactory(GsonConverterFactory.create())
                                  .build();
  newsAPI = retrofit.create(NewsAPI.class);
  Call<JSONResponse> call = newsAPI.topNews("soure", "api-key");

  call.enqueue(new Callback<JSONResponse>() {
    @Override
    public void onResponse(Call<JSONResponse> call, Response<JSONResponse> response) {
      Log.v("this", "Yes!");
    }

    @Override public void onFailure(Call<JSONResponse> call, Throwable t) {
      Log.v("this", "No Response!");
    }
  });
}
Run Code Online (Sandbox Code Playgroud)

android retrofit2

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

retrofit2 ×1