Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an ArrayAdapter with Objects. Currently I sorted it with a compare-method. It works fine, but I have to switch to elements of the entries to the first and second row.

Can you help me by finding a good solution for this.

The List consists of Category names. "Last Used" and "favs" should be at the beginning.

Should I look for these entries after sorting, or would you do this at the same moment?

share|improve this question
1  
Look at Collections.sort (developer.android.com/reference/java/util/…;, java.util.Comparator<? super T>) –  Gooziec Dec 16 '13 at 14:11
    
Thanks, i looked after that and tried with String.compareToIgnoreCase() This works pretty but only for one element. I have to. When i Use this twice, the elements will be placed at the bottom and not above all others. –  Logi24 Dec 16 '13 at 16:21
    
You can just test in the compare method if any of the items is 'Last Used' or 'Favs' and then report that item as smaller, whatever the other element is; all other items compare as usual. This will sort the two special items at the beginning of the list. –  CiaPan Mar 28 at 16:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.