Display FIREBASE image in a LISTVIEW

0

I would like to know how to recover an image in the firebase and put it in a listview, I saw some questions here, I followed the answers that are in them but none worked. I saw that a guy said he used a recyclerView and it worked, but I could not use it, could anyone help me? below is 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 that receives 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 looks like this:

    
asked by anonymous 20.07.2018 / 20:27

1 answer

0

With the link below you will understand how to create step-by-step, and in many ways, a RecycleView, which is the same ListView, but much more improved, optimized and simpler to implement.

link

One tip I give you is to use the Picaso api, link below, in it you download any image from firebase without any problem and all images remain cached, which will make your app perform excellent. / p>

link

Create an array somehow with the links and feed your RecycleView with it. That's what I would do.

    
21.07.2018 / 03:50