0

I'm having an issue with my spinner. When I debug, I can see that there is data : my adapter contains objects.

Debug spinner adapter screenshot

However, the spinner appears like it has nothing in it :

My empty spinner

Here is the (supposed) interesting code :

`

ArrayList<ActivityToSteps> activityConversionList;
ArrayList<String> activityList;  
ArrayAdapter<String> categories_adapter;

activityConversionList = new ArrayList<>();
activityList = new ArrayList<>();

categories_adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, activityList);
categories_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);


activityConversionList.addAll((ArrayList<ActivityToSteps>)task.getResult());

for(ActivityToSteps ats : activityConversionList){
    activityList.add(ats.getActivityName());
}

categories_adapter.notifyDataSetChanged();

`

ActivityToSteps is a class I created, containing a String "ActivityName" attribute and a float "StepsPerMin" attribute.

I'm getting a list of ActivityToSteps from an async task, and I want a spinner containing all their "ActivityName", stored in the ArrayList "activityList" (which is not empty, but can't show screenshot beacause reputation < 10...).

I hope I've been clear enough!

Thanks in advance for your time!!

Alexandre
  • 47
  • 5

2 Answers2

1

just forgot to set the adapter to the spinner..

spinner.setAdapter(categories_adapter);
Pavan
  • 5,016
  • 1
  • 26
  • 30
Alexandre
  • 47
  • 5
1

Please double check that you have passed your list to spinner adapter.

  your_categories_spinner.setAdapter(categories_adapter);
Adnan Bin Mustafa
  • 1,229
  • 10
  • 20