コード例 #1
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    view.setSelected(true);

    if (alphabetAdapter.getItemViewType(position) != 1) {
      Object o = alphabetAdapter.getItem(position);
      AlphabetListAdapterImgAndTwoLines.Item item = (AlphabetListAdapterImgAndTwoLines.Item) o;

      arguments = new Bundle();
      arguments.putString("cod", item.element.getData());
      arguments.putString("name", item.element.getTitulo());
    }
  }
コード例 #2
0
  private void buildListCustomFormat() {

    if (listaAdapter.size() > 0) {

      List<Row> rows = new ArrayList<Row>();
      int start = 0;
      int end = 0;
      String previousLetter = null;
      Object[] tmpIndexItem = null;
      Pattern numberPattern = Pattern.compile("[0-9]");

      for (FormatCustomListView item : listaAdapter) {

        String firstLetter = item.getTitulo().substring(0, 1);

        // Group numbers together in the scroller
        if (numberPattern.matcher(firstLetter).matches()) {
          firstLetter = "#";
        }

        // If we've changed to a new letter, add the previous letter to
        // the
        // alphabet scroller
        if (previousLetter != null && !firstLetter.equals(previousLetter)) {
          end = rows.size() - 1;
          tmpIndexItem = new Object[3];
          tmpIndexItem[0] = previousLetter.toUpperCase(Locale.UK);
          tmpIndexItem[1] = start;
          tmpIndexItem[2] = end;
          alphabet.add(tmpIndexItem);

          start = end + 1;
        }

        // Check if we need to add a header row
        if (!firstLetter.equals(previousLetter)) {
          rows.add(new Section(firstLetter));
          sections.put(firstLetter, start);
        }

        // Add the country to the list
        rows.add(new Item(item));
        previousLetter = firstLetter;
      }

      if (previousLetter != null) {
        // Save the last letter
        tmpIndexItem = new Object[3];
        tmpIndexItem[0] = previousLetter.toUpperCase(Locale.UK);
        tmpIndexItem[1] = start;
        tmpIndexItem[2] = rows.size() - 1;
        alphabet.add(tmpIndexItem);
      }

      alphabetAdapter.setRows(rows);
      lvCalle.setAdapter(alphabetAdapter);

      updateList();

      /** *********************************** */
      /** ********* <-INDEXEEERRRR ************ */
      /** ********************************** */
    }
  }