Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not showing the Spinner Selected item. #148

Open
Tarikul711 opened this issue Apr 28, 2021 · 1 comment
Open

Do not showing the Spinner Selected item. #148

Tarikul711 opened this issue Apr 28, 2021 · 1 comment

Comments

@Tarikul711
Copy link

I tried but I can't show the spinner selected item in the list.

@msbcs
Copy link

msbcs commented Mar 7, 2023

It's because the setup of the spinner needs to be done inside a successful or completed task for example :-

collectionRef.get().addOnCompleteListener(task -> {
                if (task.isSuccessful()) {
                    for (QueryDocumentSnapshot document : task.getResult()) {
                        //Log.d(TAG, document.getId() + " => " + document.getData().get("myField")); // replace 'myField' with your field name
                        categories.add((String) document.getData().get("name"));
                    }
                    //Spinner setup inside the successful task
                    ArrayAdapter<CharSequence> adapter = new
                            ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, categories);
                    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    //mySpinner.setSelection(0);
                    mySpinner.setAdapter(adapter);
                } else {
                    Log.d(TAG, "Error getting documents: ", task.getException());
                }
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants