void setData(Dish dishDetail) { dishName.setText(dishDetail.getName()); dishPrice.setText(Double.toString(dishDetail.getPrice()) + " 元/份"); int orderCount = mMyOrder.getOrderedCount(dishDetail.getId()); if (orderCount > 0) { orderedCount.setText(Integer.toString(orderCount)); } else { orderedCount.setText(" "); } }
private View getMenuView(int position, View convertView) { ItemViewHolder viewHolder; Dish dishDetail = mDishes.getDish(position); if (convertView == null) { convertView = LayoutInflater.from(MenuActivity.this).inflate(R.layout.item_dish, null); viewHolder = new ItemViewHolder(); viewHolder.findViews(convertView, ItemViewHolder.ITEM_ORDER_VIEW); viewHolder.setOnClickListener(); convertView.setTag(viewHolder); } else { viewHolder = (ItemViewHolder) convertView.getTag(); } viewHolder.setPic(position, dishDetail.getPic()); viewHolder.setData(dishDetail); viewHolder.setTag(position); return convertView; }