Ido Naveh
Ido Naveh

Reputation: 2492

An issue with Parse.com ListView tutorial

I'm having a problem with this tutorial. I have only one TextView every row. When I'm trying to populate the ListView, it looks like this:
A
A
A

instead of:
A
B
C

I mean, it shows the first row TextView text for all of the TextViews, instead of different TextViews.

This is the doInBackground method of the AsyncTask, as it shown at the tutorial:

@Override
    protected Void doInBackground(Void... params) {
        // Create the array
        worldpopulationlist = new ArrayList<WorldPopulation>();
        try {
            // Locate the class table named "Country" in Parse.com
            ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Restaurants");
            query.whereWithinKilometers("Location", SearchActivity.loc, 2.0);
            query.setLimit(5);
            ob = query.find();
            for (ParseObject country : ob) {
                WorldPopulation map = new WorldPopulation();
                map.setName((String) country.get("Name"));
                worldpopulationlist.add(map);
            }
        } catch (ParseException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

What can I do to fix this?

Upvotes: 0

Views: 94

Answers (1)

Ido Naveh
Ido Naveh

Reputation: 2492

I found out the problem. I've accidently changed private to public static on WorldPopulation class. The answer is to change it back to privatefor all of the variables, so instead of this:

public static String Name;

It will be this:

private String Name; 

Upvotes: 1

Related Questions