我的对象是食物。的 List<Food> contents;
;如何从服务器中提取数据?如何显示食物名称?我使用这个库。
我在TYPE_CELL:
的情况下改变了这一点 view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_card_promotion_item, parent, false);
TextView foodName = (TextView) view.findViewById(R.id.txt_food_name);
foodName.setText(contents.get(0).getName());
return new RecyclerView.ViewHolder(view) {
};
我这样改变。
mRecyclerView.setHasFixedSize(true);
NetworkEngine.getInstance().getFood(new Callback<List<Food>>() {
@Override
public void success(List<Food> foods, Response response) {
mContentItems = foods;
mAdapter = new RecyclerViewMaterialAdapter(new FoodRecyclerViewAdapter(foods));
mRecyclerView.setAdapter(mAdapter);
{
for (int i = 0; i < ITEM_COUNT; ++i)
mContentItems.add(new Food());
mAdapter.notifyDataSetChanged();
}
}
});