@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    View vi = convertView;
    ViewHolder holder;

    if (convertView == null) {

      /** **** Inflate tabitem.xml file for each row ( Defined below ) ****** */
      vi = inflater.inflate(R.layout.listview_row, null);

      /** **** View Holder Object to contain tabitem.xml file elements ***** */
      holder = new ViewHolder();
      holder.text = (TextView) vi.findViewById(R.id.text);
      holder.text1 = (TextView) vi.findViewById(R.id.text1);
      holder.image = (ImageView) vi.findViewById(R.id.image);

      /** ********** Set holder with LayoutInflater *********** */
      vi.setTag(holder);
    } else holder = (ViewHolder) vi.getTag();

    holder.text.setText("Company " + position);
    holder.text1.setText("company description " + position);
    ImageView image = holder.image;

    // DisplayImage function from ImageLoader Class
    imageLoader.DisplayImage(data[position], image);

    /** ****** Set Item Click Listner for LayoutInflater for each row ********** */
    vi.setOnClickListener(new OnItemClickListener(position));
    return vi;
  }
    /** Overrides newView() to inflate the list item views. */
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
      // Inflates the list item layout.
      final View itemLayout = mInflater.inflate(R.layout.contact_list_item, viewGroup, false);

      // Creates a new ViewHolder in which to store handles to each view
      // resource. This
      // allows bindView() to retrieve stored references instead of
      // calling findViewById for
      // each instance of the layout.
      final ViewHolder holder = new ViewHolder();
      holder.text1 = (TextView) itemLayout.findViewById(android.R.id.text1);
      holder.text2 = (TextView) itemLayout.findViewById(android.R.id.text2);
      holder.icon = (QuickContactBadge) itemLayout.findViewById(android.R.id.icon);
      holder.selectContact = (CheckBox) itemLayout.findViewById(android.R.id.checkbox);
      holder.selectContact.setFocusable(false);
      holder.selectContact.setClickable(false);
      holder.selectContact.setTag(tagForCheckBox);
      tagForCheckBox++;
      // Stores the resourceHolder instance in itemLayout. This makes
      // resourceHolder
      // available to bindView and other methods that receive a handle to
      // the item view.
      itemLayout.setTag(holder);

      // Returns the item layout view
      return itemLayout;
    }
Пример #3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Log.d(LOGTAG, infos.get(position));
    // TODO Auto-generated method stub
    ViewHolder viewHolder;
    if (convertView == null) {

      convertView = mLayoutInflater.inflate(R.layout.program_list_item, null);
      viewHolder = new ViewHolder();
      viewHolder.text1 = (TextView) convertView.findViewById(R.id.time);
      viewHolder.text2 = (TextView) convertView.findViewById(R.id.program);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.text1.setText(infos.get(position).getTime());
    viewHolder.text2.setText(infos.get(position).getProgram());

    if (infos.get(position).getCurProgram()) {
      viewHolder.text1.setTextColor(mContext.getResources().getColor(R.color.green));
      viewHolder.text2.setTextColor(mContext.getResources().getColor(R.color.green));
    } else {
      viewHolder.text1.setTextColor(mContext.getResources().getColor(R.color.kkblack));
      viewHolder.text2.setTextColor(mContext.getResources().getColor(R.color.kkblack));
    }

    return convertView;
  }
  /** *** Depends upon data size called for each row , Create each ListView row **** */
  public View getView(final int position, final View convertView, ViewGroup parent) {

    View vi = convertView;
    ViewHolder holder;

    if (convertView == null) {

      /** **** Inflate tabitem.xml file for each row ( Defined below ) ****** */
      vi = inflater.inflate(R.layout.desired_courses_listview, null);

      /** **** View Holder Object to contain tabitem.xml file elements ***** */
      holder = new ViewHolder();
      holder.text1 = (TextView) vi.findViewById(R.id.desiredCourseDepartment);
      holder.text2 = (TextView) vi.findViewById(R.id.desiredCourseNumber);
      holder.text3 = (TextView) vi.findViewById(R.id.desiredCourseTitle);
      holder.button1 = (Button) vi.findViewById(R.id.desiredCourseButton);

      /** ********** Set holder with LayoutInflater *********** */
      vi.setTag(holder);
    } else holder = (ViewHolder) vi.getTag();

    if (arrayList.size() <= 0) {
      //            holder.text.setText("No Data");

    } else {
      /** *** Get each Model object from Arraylist ******* */
      tempValues = null;
      tempValues = (DesiredCourseModel) arrayList.get(position);

      /** ********** Set Model values in Holder elements ********** */
      holder.text1.setText(tempValues.getDepartment());
      holder.text2.setText(tempValues.getCourse_number());
      holder.text3.setText(tempValues.getCourse_title());

      /** ****** Set Item Click Listner for LayoutInflater for each row ****** */
      holder.button1.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              try {
                arrayList.remove(getItem(position));
                notifyDataSetChanged();
                //                    notifyDataSetInvalidated();
                if (arrayList.size() <= 0) {
                  convertView.setVisibility(View.GONE);
                } else {
                  convertView.setVisibility(View.VISIBLE);
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });
    }
    return vi;
  }
Пример #5
0
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
    View itemLayout = inflater.inflate(R.layout.sample_contacts_activity_item, viewGroup, false);

    ViewHolder holder = new ViewHolder();
    holder.text1 = (TextView) itemLayout.findViewById(android.R.id.text1);
    holder.icon = (QuickContactBadge) itemLayout.findViewById(android.R.id.icon);

    itemLayout.setTag(holder);

    return itemLayout;
  }
Пример #6
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder vh = null;

    if (convertView == null) {
      vh = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.patientcase_item, null);

      vh.text1 = (TextView) convertView.findViewById(R.id.txt1);
      vh.text2 = (TextView) convertView.findViewById(R.id.txt2);
      vh.img = (ImageView) convertView.findViewById(R.id.imgCheck);
      vh.img.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              BingLiDangAnInfo info = list.get(Integer.valueOf(v.getTag() + ""));
              if (info.isChecked()) {
                info.setChecked(false);
              } else {
                info.setChecked(true);
              }
              callback.gotoDel(position);
              notifyDataSetChanged();
            }
          });

      convertView.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    BingLiDangAnInfo info = list.get(position);

    vh.img.setTag(position);
    vh.text1.setText("主治医生:" + info.getDoctorName());
    vh.text2.setText("创建日期:" + info.getTime());

    if (info.isChecked()) {
      vh.img.setImageResource(R.drawable.per_gou_yes);
    } else {
      vh.img.setImageResource(0);
    }

    return convertView;
  }
Пример #7
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder;
   if (convertView == null) {
     holder = new ViewHolder();
     LayoutInflater inflater =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     convertView = inflater.inflate(android.R.layout.two_line_list_item, null);
     convertView.setTag(holder);
     holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
     holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   Event event = getItem(position);
   holder.text1.setText(event.title);
   holder.text2.setText(event.text);
   return convertView;
 }
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.row, null);
      holder = new ViewHolder();
      holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
      holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    if ((position >= 0) && (position < essen.length)) {
      holder.text1.setText(essen[position].getName());
      holder.text2.setText(essen[position].getPreisToString());
    }

    return convertView;
  }
Пример #9
0
      public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
          convertView = getLayoutInflater(null).inflate(LAYOUT_RESOURCE, null);

          holder = new ViewHolder();
          holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);

          convertView.setTag(holder);
        } else {
          holder = (ViewHolder) convertView.getTag();
        }

        final Account account = getItem(position);

        if (account != null) {
          holder.text1.setText(account.name);
        } else {
          holder.text1.setText("");
        }

        return convertView;
      }
Пример #10
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {

      switch (getItemViewType(position)) {
        case ITEM_TYPE_VIEW:
          {
            convertView =
                (ItemListItem) inflater.inflate(R.layout.item_listitem_view, parent, false);

            ViewHolder holder = new ViewHolder();
            holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.text3 = (TextView) convertView.findViewById(R.id.text3);
            holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1);
            holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1);

            holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2);
            holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom);
            holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top);
            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_EDIT:
          {
            convertView =
                (ItemListItem) inflater.inflate(R.layout.item_listitem_equippeditem, parent, false);
            ViewHolder holder = new ViewHolder();
            holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.text3 = (TextView) convertView.findViewById(R.id.text3);
            holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1);
            holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2);
            holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom);
            holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top);
            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_SEEK:
          {
            convertView = (ViewGroup) inflater.inflate(R.layout.item_listitem_seek, parent, false);
            SeekViewHolder viewHolder = new SeekViewHolder();
            viewHolder.seek = (SeekBarEx) convertView.findViewById(R.id.wheel);
            viewHolder.text = (TextView) convertView.findViewById(R.id.wheel_label);
            viewHolder.value = (Button) convertView.findViewById(R.id.wheel_value);
            convertView.setTag(viewHolder);
            break;
          }
        case ITEM_TYPE_COMBAT_TALENT:
        case ITEM_TYPE_SIMPLE_TALENT:
          {
            convertView = inflater.inflate(R.layout.item_listitem_talent, parent, false);

            TalentViewHolder holder = new TalentViewHolder();
            // name
            holder.text1 = (TextView) convertView.findViewById(R.id.talent_list_item_text1);
            // be
            holder.text2 = (TextView) convertView.findViewById(R.id.talent_list_item_text2);
            // probe
            holder.text3 = (TextView) convertView.findViewById(R.id.talent_list_item_text3);
            // value / at
            holder.text4 = (TextView) convertView.findViewById(R.id.talent_list_item_text4);
            // pa
            holder.text5 = (TextView) convertView.findViewById(R.id.talent_list_item_text5);
            holder.indicator =
                (ImageView) convertView.findViewById(R.id.talent_list_item_indicator);
            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_MODIFIER:
          {
            // We need the layoutinflater to pick up the view from xml
            // Pick up the TwoLineListItem defined in the xml file
            convertView = inflater.inflate(R.layout.item_listitem_modifier, parent, false);

            ModifierViewHolder holder = new ModifierViewHolder();
            holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1);
            holder.active = (CheckBox) convertView.findViewById(R.id.active);
            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_HEADER:
          {
            convertView = inflater.inflate(R.layout.item_listitem_header, parent, false);

            HeaderViewHolder holder = new HeaderViewHolder();
            holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_NOTES:
          {
            convertView = inflater.inflate(R.layout.item_listitem_event, parent, false);

            EventViewHolder holder = new EventViewHolder();
            holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.text3 = (TextView) convertView.findViewById(R.id.text3);
            holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1);
            holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2);

            convertView.setTag(holder);
            break;
          }
        case ITEM_TYPE_PURSE:
          convertView = inflater.inflate(R.layout.item_listitem_purse, parent, false);
          PurseViewHolder holder = new PurseViewHolder();

          holder.currencySpinner = (Spinner) convertView.findViewById(R.id.sp_currency);
          holder.header = (TextView) convertView.findViewById(R.id.tv_currency_header);

          holder.picker = new NumberPicker[4];
          holder.picker[0] = (NumberPicker) convertView.findViewById(R.id.popup_purse_dukat);
          holder.picker[1] = (NumberPicker) convertView.findViewById(R.id.popup_purse_silver);
          holder.picker[2] = (NumberPicker) convertView.findViewById(R.id.popup_purse_heller);
          holder.picker[3] = (NumberPicker) convertView.findViewById(R.id.popup_purse_kreuzer);

          holder.labels = new TextView[4];
          holder.labels[0] = (TextView) convertView.findViewById(R.id.tv_currency1);
          holder.labels[1] = (TextView) convertView.findViewById(R.id.tv_currency2);
          holder.labels[2] = (TextView) convertView.findViewById(R.id.tv_currency3);
          holder.labels[3] = (TextView) convertView.findViewById(R.id.tv_currency4);

          convertView.setTag(holder);
          break;
      }
    }

    FlippableViewHolder.prepare(position, convertView, (ListView) parent);

    Listable item = getItem(position);

    if (item instanceof EquippedItem) {
      convertView = prepareView((EquippedItem) item, position, convertView, parent);
    } else if (item instanceof Attribute) {
      convertView = prepareView((Attribute) item, position, convertView, parent);
    } else if (item instanceof Talent) {
      convertView = prepareView((Talent) item, position, convertView, parent);
    } else if (item instanceof Spell) {
      convertView = prepareView((Spell) item, position, convertView, parent);
    } else if (item instanceof Art) {
      convertView = prepareView((Art) item, position, convertView, parent);
    } else if (item instanceof Modificator) {
      convertView = prepareView((Modificator) item, position, convertView, parent);
    } else if (item instanceof HeaderListItem) {
      convertView = prepareView((HeaderListItem) item, position, convertView, parent);
    } else if (item instanceof FileListable) {
      convertView = prepareView((FileListable) item, position, convertView, parent);
    } else if (item instanceof NotesItem) {
      convertView = prepareView((NotesItem) item, position, convertView, parent);
    } else if (item instanceof PurseListable) {
      convertView = prepareView((PurseListable) item, position, convertView, parent);
    }

    if (item instanceof Markable) {
      Util.applyRowStyle((Markable) item, convertView, position);
    } else {
      Util.applyRowStyle(convertView, position);
    }

    return convertView;
  }
  public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = inflater.inflate(R.layout.list_row, null);
      holder.text = (TextView) convertView.findViewById(R.id.title); // title
      holder.text1 = (TextView) convertView.findViewById(R.id.duration); // duration
      holder.ly = (LinearLayout) convertView.findViewById(R.id.images);
      holder.btnRealTime = (ImageButton) convertView.findViewById(R.id.realTimeButton);
      holder.realTimeData = (TextView) convertView.findViewById(R.id.realTime); // duration
      holder.mProgressView = convertView.findViewById(R.id.loginProgress);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    holder.btnRealTime.setTag(position);
    holder.realTimeData.setTag(position);

    // Fetching position-th route
    final Route path = result.get(position);

    holder.text.setText(
        path.getDeparture().getTravelTime()
            + " - "
            + path.getArrival().getTravelTime()
            + " ("
            + path.getDuration().getTravelTime()
            + ")");
    holder.text1.setText(path.getDistance());

    holder.realTimeData.setHint(
        Html.fromHtml(
            "<small><small><small>" + "Click refresh for Real Time" + "</small></small></small>"));

    final View finalConvertView = convertView;

    /*
    on click listener for the Refresh Button to fetch actual bus arrival
    time from our application server
    */
    holder.btnRealTime.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            int pos = (Integer) v.getTag();
            Log.d(TAG, "pos: " + pos + " position: " + position);
            if (pos == position) {
              showProgress(true, holder.mProgressView, holder.realTimeData);

              AucklandPublicTransportAPI api =
                  new AucklandPublicTransportAPI(
                      activity.getApplicationContext(),
                      holder.realTimeData,
                      holder.mProgressView,
                      RoutesAdaptar.this);

              for (int i = 0; i < path.getSteps().size(); i++) {
                RouteStep routeStep = path.getSteps().get(i);

                /*
                Send a reference of the TextView to AucklandPublicTransportAPI class
                in order to strike the contents of this text view when the actual
                arrival time is fetched from server for the corresponding BUS of
                a given route, as this textview displays the static scheduled time.
                 */
                if (routeStep.getTransportName() == R.string.tr_bus) {
                  TextView textView = (TextView) finalConvertView.findViewById(i);

                  api.setTextView(textView);
                  api.getRealTimeDate(
                      routeStep.getStartLoc(),
                      routeStep.getShortName(),
                      routeStep.getDeparture().getSeconds());
                  break;
                } else if (routeStep.isTransit()) {
                  break;
                }
              }
            }
          }
        });

    if (path.getSteps() != null) {

      /*
      Only if the first public transport step involves the BUS route,
      make the real Time components visible to the user. Otherwise, hide
      these components as the real time transit data is available only for
      BUSES and not for any other transit vehicle.
       */
      if (path.showrealTime()) {
        holder.btnRealTime.setVisibility(View.VISIBLE);
        holder.realTimeData.setVisibility(View.VISIBLE);
      } else {
        holder.btnRealTime.setVisibility(View.GONE);
        holder.realTimeData.setVisibility(View.GONE);
      }
      holder.ly.removeAllViews();
      populateLinks(holder.ly, path.getSteps(), path, holder.realTimeData);
    }

    return convertView;
  }