@Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (isEmpty) { ListNoneView listNoneView = new ListNoneView(context); listNoneView.setInfo("没有相关的信息"); return listNoneView; } if (convertView == null && !(convertView instanceof ListNoneView)) { holder = new ViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.home_ask_price_me_listview_item, null); holder.tvAllReplay = (TextView) convertView.findViewById(R.id.home_ask_price_me_listview_item_tv_all_replay); holder.tvFromAndTo = (TextView) convertView.findViewById(R.id.home_ask_price_me_listview_item_tv_fromAndTo); holder.tvInfo = (TextView) convertView.findViewById(R.id.home_ask_price_me_listview_item_tv_info); holder.tvDate = (TextView) convertView.findViewById(R.id.home_ask_price_me_listview_item_tv_date); holder.tvCommentCount = (TextView) convertView.findViewById(R.id.home_ask_price_me_listview_item_tv_commentCount); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } GoodsListDataForAskMe data = datas.get(position); holder.tvInfo.setText(data.getGoodsName()); holder.tvFromAndTo.setText(data.getDeparture() + " 至 " + data.getArrival()); holder.tvDate.setText("承运日期:" + data.getAcceptStartTime() + " 至 " + data.getAcceptEndTime()); holder.tvCommentCount.setText("有" + data.getInquiryAccountIds().length + "人询价"); holder.tvAllReplay.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(AskPriceActivity.this, AskPriceRelpyActivity.class); intent.putExtra("itemCode", adapterRight.getData(position).getInquiryItemCode()); intent.putExtra(AskPriceRelpyActivity.TYPE, AskPriceRelpyActivity.TYPE_REPLY_ALL); startActivity(intent); } }); return convertView; }
@Override protected void parseJSONObject(JSONObject jsonObject) throws JSONException { super.parseJSONObject(jsonObject); dataForAskMes = new ArrayList<GoodsListDataForAskMe>(); JSONArray jsonArray = jsonObject.getJSONArray("result"); for (int i = 0; i < jsonArray.length(); i++) { GoodsListDataForAskMe data = new GoodsListDataForAskMe(); JSONObject result = (JSONObject) jsonArray.get(i); data.setInquiryItemCode(result.getString("inquiryItemCode")); data.setInfoId(result.getInt("InfoId")); data.setInquiryId(result.getInt("InquiryId")); data.setDeparture(result.getString("Departure")); data.setArrival(result.getString("Arrival")); data.setAcceptStartTime(result.getString("AcceptStartTime").split("T")[0]); data.setAcceptEndTime(result.getString("AcceptEndTime").split("T")[0]); data.setInfoType(result.getString("InfoType")); data.setOrderCount(result.getInt("OrderCount")); data.setGoodsName(result.getString("GoodsName")); JSONArray jaIDs = result.getJSONArray("InquiryAccountId"); int[] ids = new int[jaIDs.length()]; for (int j = 0; j < ids.length; j++) { ids[j] = jaIDs.getInt(j); } data.setInquiryAccountIds(ids); dataForAskMes.add(data); } }