Android - null object reference when iterating List

一世执手 提交于 2019-12-01 06:04:44

Your problem is that you aren't iterating after copying list. query.findInBackground() is an async callback and therefore, isn't executed immediately. Because your iteration loop is PLACED below that callback, doesn't mean it will be executed after callback executes. Just put your loop inside callback like this:

query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> usrs, ParseException e) {
            if (e == null) {

            team_memebers = new ArrayList<String>(usrs.size());
            for (ParseObject prso:usrs) {
                team_memebers.add(new String(prso.getString("Username")));
            }
            for (String str:team_memebers)
            {
                empolyeeSpinnerAdapter.add(str);
            }
        } else {//handle the error
        }
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!