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

Apps "Cannot resolve symbol 'array' " in R.array.array_name

Elereth

Lurker
Mar 15, 2020
1
0
Trying to populate a dropdown box via a Spinner. I have a <string-array name="currencies_array"> defined and populated in strings.xml. The array in R.array.currencies_array is highlighted red saying "cannot resolve symbol 'array' ". Exact code from android documentation itself and stackoverflow articles.

Android doc for spinner under "populate the spinner with user choices: https://developer.android.com/guide/topics/ui/controls/spinner#java
StackOverflow article (based on reply by Gurinder Singh, 3rd down): https://stackoverflow.com/questions/13377361/how-to-create-a-drop-down-list

Code:
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.currencies_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dropdown.setAdapter(adapter);
 

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