0
I have to pass an Adapter string array of an Activity, which is where my database is loading into a Fragment, where I want to set this in a list, but nothing I try to do right. Would anyone have any idea?
// 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();
// This is where the list is set with adpter, within the accounts class public void Setarlista(Arrayadapter adpter){ this.lista_contas . setAdapter(adpter); }
You could post what you’ve tried?
– Denis Rudnei de Souza
look down my most recent attempt, but I’ve tried through the Bundle or even set searching for the id of the listview , if you have any idea... but thanks in advance
– Beyond Soluções
@BM_DNS, first you didn’t have to connect to the bank so direct from Activity, I advise you to create a class responsible for this. Following example: https://goo.gl/BDXCS8. With this you can search wherever you want in Activity and Fragment, but if you want to search in Activity and pass to Fragment use the standard to pass parameters to Fragments. https://stackoverflow.com/a/17436739/5140172
– Ezequiel Messore
@Ezequielmessore wrong user, Obs. Who asks the question always receives notification, no mention is required
– Denis Rudnei de Souza
@BM_DNS opa foi mals did not know it ... vlw by touch.
– Ezequiel Messore
@Ezequielmessore of good, happens
– Denis Rudnei de Souza
Vlew guy, helped a lot ... really did not know that it was not good to load in Activity... To kind that starting the studies, thank you very much helped!!!
– Beyond Soluções
But here, there’s a way to pass an Arrayadapter through the Bundle??
– Beyond Soluções