1
I have a list of products, which comes from an online database, each product contains a checkbox, name and value. What would be the best way to pass only the data of the marked products to a new Activity? It is a system similar to a shopping cart. I did not want to do with Sqlite, wanted something that was simpler. Can anyone help?
Data is saved on here:
private final List<String> idSelecionados = new ArrayList<>();
The code below represents the checkbox.
NOTE: The data would be sent to an Activity called "Details" that has only one listview...
CheckBox checMarcado  = (CheckBox) convertView.findViewById(R.id.checkBox);        
    checMarcado.setChecked(s.isMarcado());
    //Define uma tag para o checBox, para recuperar os dados quando for clicado no checkBox
    checMarcado.setTag(s);
    checMarcado.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        CheckBox check = (CheckBox) v;
        Serializando p = (Serializando) v.getTag();
        p.setMarcado(((CheckBox) v).isChecked());
        if (check.isChecked()) {
            Toast.makeText(context, "Adicionado " + p.getQuantidade()+ " - " + p.getNome(), Toast.LENGTH_SHORT).show();
            //Faz uma checagem se existe o mesmo valor na lista de inteiros
            if(!idSelecionados.contains(p.getNome())){
                //Adiciona em uma lista para poder manipular os dados depois
                idSelecionados.add(p.getNome() + p.getQuantidade());
            }
        } else {
            Toast.makeText(context, "Desmarcado " + p.getNome(), Toast.LENGTH_SHORT).show();
            //Faz uma checagem se existe o mesmo valor na lista de inteiros
            if(!idSelecionados.contains(p.getNome())){
                //Remove da lista se existir na lista
                idSelecionados.remove(p.getNome() + p.getQuantidade());
            }
        }
    }
});
tried something with Intent?
– Boneco Sinforoso
Post your code, base on it we can give you an answer!
– FlipNovid
I edited with the checkbox code... I tried with Intent yes, but I could not call in the list of Activity of Details...
– Alek