Created
September 10, 2019 11:12
-
-
Save sandeepyohans/4e13aa76d9c64c67a0ea730f2acacc78 to your computer and use it in GitHub Desktop.
Create Spinner and populate data in it - Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a collection and initialize it with data | |
ArrayList<String> list = new ArrayList<>(); | |
for (int i=0; i<10; i++) { | |
list.add("Item "+i); | |
} | |
// Create an adapter for Spinner | |
ArrayAdapter<String> spinAdapter = new ArrayAdapter<>(context,android.R.layout.simple_list_item_1, list); | |
// Set the adapter to Spinner | |
spinner.setAdapter(spinAdapter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment