• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to add livedata to spinner

towertech

Lurker
Mar 8, 2020
1
0
How can we use livedata in spinners? I have the following:

LiveData<List<Site>> sites = SiteDatabase.getInstance(this).siteDao().getAllSites();

Spinner spinner = findViewById(R.id.spinnerSites);
**What Goes Here!!*** adapter = new ArrayAdapter<Site>(this, android.R.layout.simple_dropdown_item_1line, sites);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);


Not sure how to proceed..

Thanks!!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones