I have an AutoCompleteTextView which I am trying to populate from an adapter created from values stored in Firebase. The id of the AutoCompleteTextView is medicineName Here is my code
val adapter = ArrayAdapter<String>(this,android.R.layout.simple_list_item_1)
mRef = FirebaseDatabase.getInstance().reference.child("Medicines")
mRef.addValueEventListener(object: ValueEventListener {
override fun onDataChange(dataSnapshot:DataSnapshot) {
for (suggestionSnapshot in dataSnapshot.children)
{
val suggestion = suggestionSnapshot.child("Name").getValue(String::class.java)
adapter.add(suggestion)
}
}
override fun onCancelled(databaseError:DatabaseError) {
}
})
medicineName.setAdapter(adapter)
medicineName.setOnFocusChangeListener { _, b ->
if(b) medicineName.showDropDown()
}
However, the AutoCompleteTextView does not populate with this. The structure of the Firebase data is as follows: