Guest User

Untitled

a guest
Dec 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. class FichaDeContactoCompactaAdapter (private val context : Context, private val fichasContacto : ArrayList<FichaContacto>) : RecyclerView.Adapter<FichaDeContactoCompactaAdapter.ViewHolder>() {
  2. inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v){
  3. val titulo = v.findViewById<TextView>(R.id.tituloFichaContactoCompactaTV)
  4. val editar = v.findViewById<TextView>(R.id.editarFCCTV)
  5. val eliminar = v.findViewById<TextView>(R.id.eliminarFCCTV)
  6. }
  7.  
  8. override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : ViewHolder{
  9. val v = LayoutInflater.from(parent.context)
  10. .inflate(R.layout.list_item_ficha_contacto_compacta, parent, false)
  11.  
  12. return ViewHolder(v)
  13. }
  14.  
  15. override fun onBindViewHolder(holder: ViewHolder, position: Int){
  16. holder.titulo.text = fichasContacto[position].titulo
  17.  
  18. holder.editar.setOnClickListener{
  19. Toast.makeText(holder.editar.context, "Elementos en lista: " + fichasContacto.size + "IndiceAcutal: " + position , Toast.LENGTH_SHORT).show()
  20. }
  21.  
  22. holder.eliminar.setOnClickListener{
  23. Toast.makeText(holder.eliminar.context,"Indice eliminado:" + position + "Elementos en la lista: " + fichasContacto.size, Toast.LENGTH_SHORT).show()
  24. fichasContacto.removeAt(position)
  25. notifyItemRemoved(position)
  26. }
  27. }
  28.  
  29. override fun getItemCount(): Int {
  30. return fichasContacto.size
  31. }
  32.  
  33. }
  34.  
  35. java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
Add Comment
Please, Sign In to add comment