1
I would like to know how to recover an image in firebase and put in a listview, I saw here some similar questions, followed the answers that are in them but none worked. I saw that a boy said he used a recyclerView and it worked, but I could not use it, could someone help me? follows below the code
ADAPTER
public View getView(int position, View convertView, ViewGroup parent) {
View view = act.getLayoutInflater().inflate(R.layout.lista_sessao_personalizada, parent, false);
Sessoes sessao = sessoes.get(position);
TextView nome = (TextView) view.findViewById(R.id.lista_sessao_personalizada_nome);
TextView descricao = (TextView) view.findViewById(R.id.lista_sessao_personalizada_descricao);
final ImageView imagem = (ImageView) view.findViewById(R.id.lista_sessao_personalizada_imagem);
nome.setText(sessao.getNomeSessao());
descricao.setText(sessao.getDescricaoSessao());
firebase = ConfiguracaoFirebase.getFirebase().child("configuracao").child("telaInicial").child("calendario");
ValueEventListener post = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String imagemFire = dataSnapshot.getValue().toString();
Glide.with(act).load(imagemFire).into(imagem);
Log.i("imagem", imagemFire);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
firebase.addValueEventListener(post);
// Glide.with(act).load(imagemFire).into(imagem);
return view;
}
}
Activity receiving the Adapter
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logoImg = findViewById(R.id.logo_doeamor_id);
firebase = ConfiguracaoFirebase.getFirebase().child("configuracao").child("telaInicial").child("logo");
ValueEventListener post = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String imagem = dataSnapshot.getValue().toString();
Glide.with(getApplicationContext()).load(imagem).into(logoImg);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
firebase.addValueEventListener(post);
sessoes = todasAsSessoes();
listaDeSessoes = (ListView) findViewById(R.id.listaDeSessoes);
AdapterPersonalizado adapter = new AdapterPersonalizado(sessoes, MainActivity.this);
listaDeSessoes.setAdapter(adapter);
}
and the image comes out like this: