我在选项卡式活动中使用多个片段来显示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)