view raw
Mad Hatter Mad Hatter - 5 months ago 52
Android Question

Array returns every item on every row instead of one item per row

I am trying to set a number of languages in a recycler view using a set which I converted into an array. I don't really understand why this results in every language being displayed on each row. Any pointers would be gratefully received. Here is my code:

public void onInit(int initStatus) {
if (initStatus == TextToSpeech.SUCCESS) {
availableLanguages = myTTS.getAvailableLanguages();
Locale[] arrayLocale = availableLanguages.toArray(new Locale[availableLanguages.size()]);
String locDisplayResults = Arrays.toString(arrayLocale);

for (int i = 1; i < arrayLocale.length; i++) {
languagesList.add(new Language(arrayLocale[i], locDisplayResults));
Collections.sort(languagesList, new Comparator<Language>() {
public int compare(Language languages1, Language languages2) {
return languages1.getLocaleDisplay().compareTo(languages2.getLocaleDisplay());



This code "Arrays.toString(arrayLocale);" will give you a string with all the elements. You are assigning this to the variable "locDisplayResults" and sets this on all lines in languagesList it seems. I think that is the problem.