简体   繁体   English

从Parse.com获取到Android Spinner的列表

[英]List obtained from Parse.com to an Android Spinner

I'm trying to get an array list from parse.com and insert it into a Spinner to have more control of my app. 我正在尝试从parse.com获取数组列表,并将其插入Spinner中,以更好地控制我的应用程序。 I've seen how to add things via code to a Spinner, but I've not been able to retrieve a list from Parse and put it into the spinner. 我已经看到了如何通过代码将内容添加到微调器中,但是我无法从Parse中检索列表并将其放入微调器中。

Any help would be appreciated. 任何帮助,将不胜感激。

ParseQuery<ParseObject> query = ParseQuery.getQuery("Modelos");
        try {
            mod = query.find();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(mod.get(1).toString());

With the code above I'm able to get the Object as it is but I'm not able to access any attributes. 使用上面的代码,我可以按原样获取对象,但无法访问任何属性。 My output gets: 我的输出得到:

I/System.out﹕ com.parse.ParseObject@425b9c78

First you can see here to retrieve a List of ParseObject, after you have the List you only need a adapter to show the information what you like, here have an example. 首先,您可以在这里看到检索ParseObject的列表,获得列表后,您只需要一个适配器即可显示所需信息, 这里有一个示例。

EDIT 编辑

Remember the index in java start in 0, after that if you call toString in some ParseObject you only get the string representation of any java object, because isn't implemented the toString method in ParseObject. 请记住,java中的索引从0开始,此后,如果您在某个ParseObject中调用toString,则您只会获得任何Java对象的字符串表示形式,因为在ParseObject中未实现toString方法。

To access to the information retrieved in some ParseObject you need call getString, getInt, getDouble, etc. 要访问在某些ParseObject中检索到的信息,您需要调用getString,getInt,getDouble等。

Log.d("ParseObject", mod.get(0).getString("column_name"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM