Why doesn’t the code show in the spinner the data of the "settlement" table in the firebase?

Asked

Viewed 5 times

-2

    spListaAssentamentos = findViewById(R.id.spListaAssentamentos);
    nomeAssentamento = new ArrayList<>();

    databaseReference = FirebaseDatabase.getInstance().getReference();
    databaseReference.child("assentamento").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot snapshot) {
            for(DataSnapshot chilSnapshot:snapshot.getChildren()) {
                String spinnerNome = snapshot.child("nomeAreaInteresse").getValue(String.class);
                nomeAssentamento.add(spinnerNome);
            }
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(FormularioCadastroImovelActivity.this, android.R.layout.simple_spinner_item, nomeAssentamento);
            arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
            spListaAssentamentos.setAdapter(arrayAdapter);

        }

        @Override
        public void onCancelled(@NonNull DatabaseError error) {

        }

    });
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.