Beispiel #1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = _inflater.inflate(R.layout.listitem_selectroute, parent, false);
      _setViewHolder(convertView);
    } else if (((TransportCellViewHolder) convertView.getTag()).needInflate) {
      convertView = _inflater.inflate(R.layout.listitem_selectroute, parent, false);
      _setViewHolder(convertView);
    }

    TransportCellViewHolder vh = (TransportCellViewHolder) convertView.getTag();

    vh.leftText.setText(getItem(position).routeNumber);
    Pair<Integer, Integer> res = vh.backgroundAndIconByKind(getItem(position).kind);
    convertView.setBackgroundResource(res.first);
    vh.leftIcon.setImageResource(res.second);

    String fullName = getItem(position).fullName;
    TextView fullNameTextView = vh.rightText;
    if (fullName == null) {
      fullNameTextView.setVisibility(View.INVISIBLE);
    } else {
      fullNameTextView.setText(fullName);
      fullNameTextView.setVisibility(View.VISIBLE);
    }

    return convertView;
  }
Beispiel #2
0
 private void _setViewHolder(View view) {
   TransportCellViewHolder vh = new TransportCellViewHolder();
   vh.leftIcon = (ImageView) view.findViewById(R.id.listItemSelectRouteKind);
   vh.leftText = (TextView) view.findViewById(R.id.listItemSelectRouteRouteName);
   vh.rightText = (TextView) view.findViewById(R.id.listItemSelectRouteFullName);
   vh.needInflate = false;
   view.setTag(vh);
 }
Beispiel #3
0
 public void removeRoute(int position, View view) {
   TransportCellViewHolder vh = (TransportCellViewHolder) view.getTag();
   vh.needInflate = true;
   remove(getItem(position));
   notifyDataSetChanged();
 }