-4

Here is my code:

public class XMLGettersSetters {
    private ArrayList<String> country = new ArrayList<String>();

    public ArrayList<String> getCountry() {
        return country;
    }

    public void setCountry(String countryValue) {
        this.country.add(countryValue);
        Log.i("Countries", countryValue);
    }

In LogCat it shows all the data, but when I am returning it and trying to show it in a ListView it is just showing the last value of the list, not all. Am I missing something?

kabuko
  • 36,028
  • 10
  • 80
  • 93
  • 1
    I think your missing some code here man. What you gave doesn't seem complete and I can't help you with what I got – Frank Sposaro Feb 23 '12 at 18:36
  • I am setting the country from another class and the values ar being added in the arraylist, but when i m getting this returned arraylist its showing the last value of what it gets, but in the log cat it shows all the values – Sabbir Ahmed Reyjohn Feb 23 '12 at 19:02

1 Answers1

0

Just some points with what I see so far.

  1. Your return type for getCountry should be ArrayList you are missing the type.
  2. I would call it setCountry because you aren't setting, you are adding to the list.

Perhaps it's something to do with the length you are returning in your adapter?

Romain Hippeau
  • 24,113
  • 5
  • 60
  • 79
Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
  • I m setting the value from another class, and its showing all the value in logcat, but when i return it, it shows the one value, i think its overwriting the value, how to solve it? – Sabbir Ahmed Reyjohn Feb 23 '12 at 19:00
  • yeah. So without the ability to view the code I can only guess. And my guessing are you are return only one item and not the entire array. Check your return type. or your length is set to 1 somewhere so it's only giving you one element. – Frank Sposaro Feb 23 '12 at 20:08