private void SetAction(LinearLayout view, final Order order) { Button btnAction = (Button) view.findViewById(R.id.btnAction); // 根据不同的订单页面动作按钮显示不同的文字信息: switch (order.status) { case OrderActivity.ORDER_TYPE_NEW: // 接受订单: btnAction.setText(orderActivity.getString(R.string.btn_action_new)); break; case OrderActivity.ORDER_TYPE_ACCEPT: // 开始配送: btnAction.setText(orderActivity.getString(R.string.btn_action_accept)); break; case OrderActivity.ORDER_TYPE_EXPRESS: // 配送完成: btnAction.setText(orderActivity.getString(R.string.btn_action_express)); break; default: } // 开始/完成配送的按键事件: btnAction.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { orderActivity.updateOrder(order.orderID, order.status + 1); } }); }
private void SetPayment(LinearLayout view, Order order) { TextView txtPayment = (TextView) view.findViewById(R.id.txtPayment); // 订单金额信息: String strPayment = String.valueOf(order.payment) + orderActivity.getString(R.string.pay_unit); // 在线支付类文字颜色: if (order.payType == Order.PAY_TYPE_ONLINE) { strPayment += orderActivity.getString(R.string.pay_type_online); txtPayment.setTextColor(orderActivity.getResources().getColor(R.color.pay_type_online)); } // 货到付款类文字颜色: else if (order.payType == Order.PAY_TYPE_OFFLINE) { strPayment += orderActivity.getString(R.string.pay_type_offline); txtPayment.setTextColor(orderActivity.getResources().getColor(R.color.pay_type_offline)); } txtPayment.setText(strPayment); }
private void SetSelected(int position, LinearLayout view, Order order) { LinearLayout orderExtendLayout = (LinearLayout) view.findViewById(R.id.orderExtendLayout); LinearLayout orderCommandLayout = (LinearLayout) view.findViewById(R.id.orderCommandLayout); LinearLayout orderDetailLayout = (LinearLayout) view.findViewById(R.id.orderDetailLayout); // 选中项展示详情和命令列表: if (position == orderActivity.mCurrentPostion && orderExtendLayout.getVisibility() == View.GONE) { // 显示扩展信息区: orderExtendLayout.setVisibility(View.VISIBLE); // 清除原有控件: orderDetailLayout.removeAllViews(); // 设定订单详情文本框格式: LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.leftMargin = 50; // 逐条加载详情信息: OrderItem item; for (int i = 0; i < order.items.size(); i++) { item = order.items.get(i); TextView detailText = new TextView(orderActivity); detailText.setTextColor(orderActivity.getResources().getColor(R.color.detail_content)); detailText.setText( orderActivity.getString(R.string.content_detail_header) + item.itemName + " ( " + item.itemCount + " ) : " + item.itemAmount + orderActivity.getString(R.string.pay_unit)); orderDetailLayout.addView(detailText, lp); } // 添加配送信息文本框: TextView expressText = new TextView(orderActivity); expressText.setText( orderActivity.getString(R.string.content_detail_header) + orderActivity.getString(R.string.content_express_price) + " : " + order.expressPrice + orderActivity.getString(R.string.pay_unit)); expressText.setTextColor(orderActivity.getResources().getColor(R.color.detail_content)); orderDetailLayout.addView(expressText, lp); // 结算页不显示操作命令列表: if (order.status == OrderActivity.ORDER_TYPE_BALANCE) orderCommandLayout.setVisibility(view.GONE); else orderCommandLayout.setVisibility(view.VISIBLE); } else { // 自动隐藏之前选择项扩展信息区: if (orderExtendLayout.getVisibility() == View.VISIBLE) orderExtendLayout.setVisibility(View.GONE); } }