来自字段的ParseQuery不保存

时间:2016-10-14 18:11:52

标签: java android parse-platform field

ItemCount字段无法正常工作

CategoryModel构造是ItemCount = 0无法正常工作

ParseObject parseObjectCategory = Categorylist.get(i);

                        ParseQuery<ParseObject> query = ParseQuery.getQuery("List");
                        query.whereEqualTo("parent", parseObjectCategory);

                        query.findInBackground(new FindCallback<ParseObject>() {
                            public void done(List<ParseObject> scoreList, ParseException e) {
                                if (e == null) {
                                    itemCount = scoreList.size();
                                    Log.e("ItemCountGENERAL",""+itemCount);
                                } else {
                                    Log.e("Aldaa","---------------------------------------------------------------");
                                }
                                itemCount = scoreList.size();
                            }
                        });

                        Log.e("ItemCount",""+itemCount);

                        if(name.equals("Inbox")){
                            categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_inbox, itemCount);
                        }else if(name.equals("Stared")){
                            categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_stars, itemCount);
                        }else{
                            categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_inbox, itemCount);
                        }

                        mainData.add(categoryMode1);
                        mainAdapter.notifyDataSetChanged();
                    }`

我的形象:

enter image description here

  

帮助我   www.google.mn

1 个答案:

答案 0 :(得分:0)

您应该添加这些代码

                    if(name.equals("Inbox")){
                        categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_inbox, itemCount);
                    }else if(name.equals("Stared")){
                        categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_stars, itemCount);
                    }else{
                        categoryMode1= new CategoryModel(itemData,name,R.drawable.ic_inbox, itemCount);
                    }

                    mainData.add(categoryMode1);
                    mainAdapter.notifyDataSetChanged();` 

进入FinalCallbackitemCount得到0,因为你在未初始化的字段中调用。 itemCountFinalCallback内部获取其值,该值在单独的非UI线程中运行,这意味着您访问它的UI线程可以在非UI线程之前运行。因此,您应该将使用从解析中检索到的数据的逻辑移动到FinalCallback