I have a spinner widget in my activity. If I run the app on my device (Pie version) the spinner works fine but if I run it on emulator (which has lollipop version- requirements of work)- spinner doesn't show any items at all.
So this is my activity code for the spinner (inside onCreate):
spinner = (Spinner) findViewById(R.id.spinner_reminder_times);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getApplicationContext(),
R.array.reminder_times_array, android.R.layout.simple_spinner_dropdown_item);
// Specify the layout to use when the list of choices appears
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the spinnerAdapter to the spinner
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(this);
And this is the implemented method:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (parent.getSelectedItemPosition()) {
case 0:
// do stuff
break;
case 1:
// do stuff
break;
case 2:
// do stuff
break;
}
}
The spinner xml in activity_layout:
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinner_reminder_times"
android:theme="@style/ThemeOverlay.AppCompat.Light"
android:spinnerMode="dropdown">
</Spinner>
What may be the problem? how comes it works perfectly on my device but on android lollipop emulator doesn't show anything? Thanks!