public class BookActivity extends AppCompatActivity {
private BookBiz bookBiz=new BookBiz();
private List<BookList.DataBean> mData=new ArrayList<>();
private BookListAdapter adapter;
private ListView mlistView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book);
mlistView=findViewById(R.id.book_lv);
initView();
}
private void initView() {
bookBiz.listView(new BookCallback<List<BookList.DataBean>>() {
@Override
public void onError(Exception ex) {
}
@Override
public void onSuccess(List<BookList.DataBean> response) {
if (response.size()==0){
Log.e("List","返回结果是空");
return;
}
mData.addAll(response);
Log.e("main1","数据"+mData.size());
}
});
Log.e("main2","数据"+mData.size());
adapter=new BookListAdapter(this,mData);
mlistView.setAdapter(adapter);
}
protected static void start(Context context){
Intent intent=new Intent(context,BookActivity.class);
context.startActivity(intent);
}
}我在后台的log显示的main1 有数据可是在main2里显示没有数据。在Callback返回有数据 可是就是拿不到
1 回答
离歌丶D
TA贡献2条经验 获得超0个赞
bookBiz.listView(new BookCallback<List<BookList.DataBean>>() { @Override public void onError(Exception ex) { } @Override public void onSuccess(List<BookList.DataBean> response) { if (response.size()==0){ Log.e("List","返回结果是空"); return; } mData.addAll(response); //这里需要更新一下adapter中的数据 Log.e("main1","数据"+mData.size()); } });
- 1 回答
- 0 关注
- 880 浏览
添加回答
举报
0/150
提交
取消