@Override public View getView(int position, View convertView, ViewGroup parent) { index = position; final JsonBeanInfo info = (JsonBeanInfo) mList.get(position); convertView = mInflater.inflate(R.layout.notice_beijing_single_listview_item, null); final ViewHolder holder = new ViewHolder(); holder.teamId = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_team_id); holder.team = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_team); holder.home = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_team_name1); holder.away = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_team_name2); holder.letPoint = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_vs); holder.result = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_jieguo); holder.score = (TextView) convertView.findViewById(R.id.jc_main_list_item_text_score); holder.sp = (TextView) convertView.findViewById(R.id.notice_beijing_single_item_odds); convertView.setTag(holder); holder.sp.setVisibility(View.GONE); holder.team.append(info.getTeam()); holder.teamId.append(info.getTeamId()); holder.result.append(info.getResult()); String score = info.getGuestScore() + ":" + info.getHomeScore(); holder.score.append(score); holder.home.append(info.getAway() + "(客)"); holder.away.append(info.getHome() + "(主)"); if (Constants.LOTNO_JCLQ_RF.equals(playMethodType)) { if (!"".equals(info.getLetPoint())) { holder.letPoint.setText(info.getLetPoint()); holder.letPoint.setTextColor(Color.BLUE); } } else if (Constants.LOTNO_JCLQ_DXF.equals(playMethodType)) { if (!"".equals(info.getBasePoint())) { holder.letPoint.setText(info.getBasePoint()); holder.letPoint.setTextColor(Color.BLUE); } } convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { trunExplain(getEvent(Constants.JCBASKET, info)); } }); return convertView; }
/** 子列表中相应的数据 */ protected List<JsonBeanInfo> getSubInfoForListView(JSONObject jsonObj) { ArrayList<JsonBeanInfo> list = new ArrayList<JsonBeanInfo>(); try { if (initViewState == FIRST_JC_NOTICE) { dateStr = jsonObj.getString("date"); formatDate(dateStr); } JSONArray jsonArray = jsonObj.getJSONArray("result"); for (int i = 0; i < jsonArray.length(); i++) { JsonBeanInfo itemInfo = new JsonBeanInfo(); JSONObject jsonItem = jsonArray.getJSONObject(i); itemInfo.setDay(jsonItem.getString("day")); itemInfo.setWeekId(jsonItem.getString("weekId")); itemInfo.setTeamId(jsonItem.getString("teamId")); itemInfo.setTeam(jsonItem.getString("league")); itemInfo.setResult(jsonItem.getString("matchResult")); itemInfo.setLetPoint(jsonItem.getString("letPoint")); if (jsonItem.has("basePoint")) { itemInfo.setBasePoint(jsonItem.getString("basePoint")); } itemInfo.setHome(jsonItem.getString("homeTeam")); itemInfo.setAway(jsonItem.getString("guestTeam")); itemInfo.setHomeScore(jsonItem.getString("homeScore")); itemInfo.setGuestScore(jsonItem.getString("guestScore")); list.add(itemInfo); } } catch (JSONException e) { e.printStackTrace(); } return list; }
public String getEvent(String type, JsonBeanInfo info) { return type + "_" + info.getDay() + "_" + info.getWeekId() + "_" + info.getTeamId(); }