0

in my app Android I have a set of data I want to bind to a spinner.
But of these I would like a particular value to be seen as the first in the spinner list.

public String [] getDescriptionCategories () {
     Set <String> categories = products.keySet ();
     String [] result = new String [categorie.size ()];
     int i = 0;
     for (String cat: categories) {
         result [i ++] = cat;
     }

     return result;
 }

The result is ["Altro","Prodotti","Utenti"], but I wish it was ["Utenti", "Prodotti", "Altro"]

How do I set it up?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Enda Azi
  • 49
  • 10

2 Answers2

0

You should use return Collections.reverse(result);. It will reverse your list. If you want to sort the list by alphabetical order, see this answer. Hope it helps :)

0

Use Collection class ie sort(List) and reverse(List)

kubs
  • 117
  • 9