Fragments and how to pass activity information to them

0

I have to pass an array string adapter from an activity, which is where my bank is loading into a fragment, where I want to put that in a list, but nothing that I try for right. Would anyone have any ideas?

   // Banco

    try{
        database=new DataBase(this);

        conn = database.getWritableDatabase();

        res = new Repositorio(conn);
        res.testeinserir();


        // esse adpter recebe a lista vindo do banco 
        this.adpter = res.ListContas(this);


        Toast.makeText(this, "Conexão feita com sucesso!", Toast.LENGTH_SHORT).show();

    }
    catch(SQLException ex){
        Toast.makeText(this,"Erro ao se conectar ao banco!",Toast.LENGTH_SHORT).show();
    }

     //Aqui é onde mando a lista para o metodo setar lista que ta dentro da Classe Contas, que eu instanciei como adp  

    Runnable r = new Runnable() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if(adp != null){
                        adp.SetarLista(adpter);
                    }
                }
            });
        }
    };
    Thread t = new Thread(r);
    t.start();

// Here is where the list is set with adpter, within the class accounts     public void SetarList (ArrayAdapter adpter) {         this.listAdapter (adpter);     }

    
asked by anonymous 23.07.2017 / 08:21

1 answer

0

Create a custom Adapter and deploy the Serializable interface. To use in ListView I use the Base Adapter:

public class MeuAdapter extends BaseAdapter implements Serializable

In this way, it will be possible to pass this Adapter instance through the Bundle with putSerializable("meuAdapter", meuAdapter) .

    
25.07.2017 / 14:48