标签:get bsp vertica content toast array tco .data back
private OkHttpClient mOkHttpClient; private RecyclerView mRecycle_View; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); mOkHttpClient = new OkHttpClient.Builder().build(); init(); } private void initView() { mRecycle_View = (RecyclerView) findViewById(R.id.mRecycle_View); } private void init() { new Retrofit.Builder() .baseUrl("http://www.qubaobei.com/") .client(mOkHttpClient) .addConverterFactory(GsonConverterFactory.create()) .build() .create(HttpCall.class) .getHttpBean_mainCall(1,20,1) .enqueue(new Callback<Bean>() { @Override public void onResponse(Call<Bean> call, Response<Bean> response) { ArrayList<Bean.DataBean> data = (ArrayList<Bean.DataBean>) response.body().getData(); MyAdapter adapter = new MyAdapter(data, MainActivity.this); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL); mRecycle_View.setAdapter(adapter); mRecycle_View.setLayoutManager(layoutManager); } @Override public void onFailure(Call<Bean> call, Throwable t) { Toast.makeText(MainActivity.this, "失败", Toast.LENGTH_SHORT).show(); } });
标签:get bsp vertica content toast array tco .data back
原文地址:https://www.cnblogs.com/98k98k/p/8986423.html