1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to add livedata to spinner

Discussion in 'Android Development' started by towertech, Mar 8, 2020.

  1. towertech

    towertech Lurker
    Thread Starter

    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!!
     


Loading...

Share This Page

Loading...