public void addItem( String terminalid, String terminalname, String terminallatitude, String terminallongitude, String terminaladdress, String terminalopenstate, String terminalman, String terminalphone) { TerminalItem item = new TerminalItem(); item.setTerminalid(terminalid); item.setTerminalname(terminalname); item.setTerminallatitude(terminallatitude); item.setTerminallongitude(terminallongitude); item.setTerminaladdress(terminaladdress); item.setTerminalopenstate(terminalopenstate); item.setTerminalman(terminalman); item.setTerminalphone(terminalphone); list.add(item); }
@Override public View getView(int position, View convertView, ViewGroup parent) { TerminalItem item = list.get(position); View view = null; if (convertView != null) { view = convertView; } else { view = inflater.inflate(R.layout.terminal_list_item, parent, false); } ItemViewHolder holder = (ItemViewHolder) view.getTag(); if (holder == null) { holder = new ItemViewHolder(); holder.tv_terminalname = (TextView) view.findViewById(R.id.tv_terminalname); holder.tv_terminaladdress = (TextView) view.findViewById(R.id.tv_terminaladdress); holder.tv_terminalman = (TextView) view.findViewById(R.id.tv_terminalman); holder.tv_terminalphone = (TextView) view.findViewById(R.id.tv_terminalphone); view.setTag(holder); } if (item != null) { holder.tv_terminalname.setText(item.getTerminalname()); holder.tv_terminalname.setOnTouchListener(new TextViewDrawableOnTouchListener()); holder.tv_terminalname.setTag(item.getTerminalid() + "," + position); holder.tv_terminaladdress.setText(item.getTerminaladdress()); if (TextUtils.isEmpty(item.getTerminalman())) { holder.tv_terminalman.setText("无联系人"); } else { holder.tv_terminalman.setText(item.getTerminalman()); } if (TextUtils.isEmpty(item.getTerminalphone())) { holder.tv_terminalphone.setText("无联系电话"); } else { holder.tv_terminalphone.setText(item.getTerminalphone()); } } return view; }