检索parse.com数组和值添加到本地阵列(Android版) [英] Retrieve an array from parse.com and add the values to a local array (Android)

查看:120
本文介绍了检索parse.com数组和值添加到本地阵列(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从parse.com在用户类被称为根的数组列,我想要从列数组对象,然后提取值(字符串)到一个数组在我的申请。

I have an array column called "Roots" in a user class from parse.com and I want to retrieve the array object from the column and then extract the values (strings) to an array in my application.

ParseUser.logInInBackground(user, password, new LogInCallback() {
                public void done(ParseUser user, ParseException e) {
                    if (user != null) {
                        // Hooray! The user is logged in.
                        startMenu();
                        String[] testStringArray = (String[])user.get("Roots");

我不知道,如果最后一行甚至可以。即使是这样,我不知道如何提取单个元素,并将它们设置为本地数组,我可以使用索引例如调用。

I'm not sure if the last line even works. Even if it does, I'm not sure how to extract the individual elements and set them to a local array that I can call on using an index e.g.

String myString = testStringArray[1]

或一些这样的。我曾尝试上述code的一些变化,我觉得我失去了一些东西根本。有没有人有我如何才能做到这一点的例子吗?
在此先感谢!

Or some such. I have tried a few variations of the above code and I think I am missing something fundamental. Does anyone have an example of how I can accomplish this? Thanks in advance!

推荐答案

使用的的ArrayList<弦乐> 而不是的String [] ,那么你就可以访问它,就像任何其他的ArrayList对象。

Use an ArrayList<String> instead of String[], then you can access it as you would any other ArrayList object.

ArrayList<String> testStringArrayList = (ArrayList<String>)user.get("Roots");
String myString = testStringArrayList.get(1);

这篇关于检索parse.com数组和值添加到本地阵列(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆