Parse.com ListView教程的一个问题

时间:2015-06-24 08:38:20

标签: android listview parse-platform textview

我遇到this教程的问题。 我每行只有一个TextView。 当我尝试填充ListView时,它看起来像这样:
一个
一个

代替:
一个

ç

我的意思是,它显示了所有TextView的第一行TextView文本,而不是不同的TextView。

这是AsyncTask的doInBackground方法,如教程中所示:

@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;
    }

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

我发现了问题。我在WorldPopulation类上意外地将private更改为public static。答案是将其更改为私有所有变量,所以不要这样:

public static String Name;

就是这样:

private String Name;