Update Fragment from CardView

0

Let's see if anyone can help me.

I have a Fragment in which I have several TextView with data and a RecycleView . Within CardView of RecycleView I have a boton for each item in the list. I want to press the button to update the values of TextView that I have in Fragment .

Putting in example .. the RecycleView contains a list of products that I have sold. and a TextView contains the total price of the sale. If I click on the CardView button, I remove one of those products. To update the value in the TextView.

public ViewHolder(View itemView ){
            super(itemView);
        contexto=itemView.getContext();
        txtreferencia=(TextView) itemView.findViewById(R.id.txtreferencia);
        txtcantidad=(TextView) itemView.findViewById(R.id.txtcantidad);
        txtdescripcion=(TextView) itemView.findViewById(R.id.txtdescripcion);
        txtdescripcion=(TextView) itemView.findViewById(R.id.txtdescripcion);
        txtid=(TextView) itemView.findViewById(R.id.txtid);
        btneliminar=(Button) itemView.findViewById(R.id.btneliminarpiezapedido);

        card=(CardView)itemView.findViewById(R.id.cardpiezas);
      // btnlocalizar=(Button)itemView.findViewById(R.id.btnlocalizar);
        btneliminar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                borrar_pieza(Integer.parseInt(txtid.getText().toString()));
        AQUI QUIERO ACTULIZAR  LOS VALORES DEL FRAGMENT QUE CONTIENE EL RECYCLERVIEW
            }
        });
    }

Thanks for the help.

    
asked by francisco Varela 25.04.2018 в 18:02
source

1 answer

0

In the end I solved the problem by declaring static fragment views. From the button the CardView call still update procedure.

 btneliminar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                borrar_pieza(Integer.parseInt(txtid.getText().toString()));
                actuacion a=new actuacion();
                a.actualizar();
            }
        });
public RecyclerView actualizar(){

    this.listadodepiezas.setLayoutManager(new LinearLayoutManager(getActivity()));
    Clase_lista_piezas_pedido clase_pieza =new Clase_lista_piezas_pedido();
    ArrayList<Clase_lista_piezas_pedido> pieza=clase_pieza.Obtener_piezas_pedido(naviso);
    adaptador=new Recicle_listapiezaspedidas(pieza);
    this.listadodepiezas.setAdapter(adaptador);

    return this.listadodepiezas;
}
    
answered by 10.05.2018 в 20:59