Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FichaDeContactoCompactaAdapter (private val context : Context, private val fichasContacto : ArrayList<FichaContacto>) : RecyclerView.Adapter<FichaDeContactoCompactaAdapter.ViewHolder>() {
- inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v){
- val titulo = v.findViewById<TextView>(R.id.tituloFichaContactoCompactaTV)
- val editar = v.findViewById<TextView>(R.id.editarFCCTV)
- val eliminar = v.findViewById<TextView>(R.id.eliminarFCCTV)
- }
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : ViewHolder{
- val v = LayoutInflater.from(parent.context)
- .inflate(R.layout.list_item_ficha_contacto_compacta, parent, false)
- return ViewHolder(v)
- }
- override fun onBindViewHolder(holder: ViewHolder, position: Int){
- holder.titulo.text = fichasContacto[position].titulo
- holder.editar.setOnClickListener{
- Toast.makeText(holder.editar.context, "Elementos en lista: " + fichasContacto.size + "IndiceAcutal: " + position , Toast.LENGTH_SHORT).show()
- }
- holder.eliminar.setOnClickListener{
- Toast.makeText(holder.eliminar.context,"Indice eliminado:" + position + "Elementos en la lista: " + fichasContacto.size, Toast.LENGTH_SHORT).show()
- fichasContacto.removeAt(position)
- notifyItemRemoved(position)
- }
- }
- override fun getItemCount(): Int {
- return fichasContacto.size
- }
- }
- java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
Add Comment
Please, Sign In to add comment