@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (alphabetAdapter.getItemViewType(position) != 1) { Object o = alphabetAdapter.getItem(position); AlphabetListAdapterImgAndTwoLinesLead.Item item = (AlphabetListAdapterImgAndTwoLinesLead.Item) o; if (item.element.getExtra2().equals("1") || item.element.getExtra2().equals("2")) { boolean crear = false; boolean actualizar = false; boolean rechazar = false; boolean aprobar = false; if (movilCrear.equalsIgnoreCase("Y")) crear = true; if (movilEditar.equalsIgnoreCase("Y")) actualizar = true; if (movilRechazar.equalsIgnoreCase("Y")) rechazar = true; if (movilAprobar.equalsIgnoreCase("Y")) aprobar = true; if (!crear && !actualizar && !rechazar && !aprobar) { Toast.makeText(contexto, "No tiene permisos para realizar acciones", Toast.LENGTH_SHORT) .show(); return false; } else { CustomDialogSocio cd = new CustomDialogSocio(); Dialog groupDialog = cd.CreateGroupDialog( contexto, "sn", item.element.getTitulo(), crear, actualizar, rechazar, aprobar); groupDialog.show(); } } } return true; }
private void buildListCustomFormat() { if (listaAdapter.size() > 0) { // adapter = new ListViewCustomAdapterImgAndTwoLinesWithFormat( // contexto, listaAdapter); 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.getData().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); lvSN.setAdapter(alphabetAdapter); updateList(); /** *********************************** */ /** ********* <-INDEXEEERRRR ************ */ /** ********************************** */ lvSN.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent myIntent = new Intent(v.getContext(), DetalleSocioNegocioMain.class); if (alphabetAdapter.getItemViewType(position) != 1) { Object o = alphabetAdapter.getItem(position); AlphabetListAdapterImgAndTwoLinesLead.Item item = (AlphabetListAdapterImgAndTwoLinesLead.Item) o; myIntent.putExtra("id", item.element.getTitulo()); myIntent.putExtra("tipo", "Lead"); startActivity(myIntent); } } }); } }