解析:如何设置一个指针的Andr​​oid? [英] Parse: How to set a pointer in Android?

查看:99
本文介绍了解析:如何设置一个指针的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我目前的类,比方说,我有一列是一个指向另一个类,说B.任何人都可以请让我知道我可以在Android的此列?

In my current class, say A, I have a column which is a pointer to another class, say B. Can anyone please let me know how I can set a value for this column in Android?

我曾尝试获取来自B类要求的行作为的parseObject,并做了:

I have tried fetching the required row from class B as a ParseObject, and doing a:

classAObject.put("column_name",classBParseObject);

不过,这只是我的A级创建一个空行,没有指针。在这方面的任何帮助是非常AP preciated。

But, this is just creating an empty row in my class A, with no pointers. Any help in this regard is much appreciated.

推荐答案

如果您有计算机科学课程ID的OBJECTID,那么你需要使用createWithoutData方法保存。因此,让我们回顾一下:你有一个叫CourseId列学生表 - 这是一个指向课程表,而不是课程表的CourseId列。你不能指向一个栏,你点到一个表。

If you have the objectID of the course ID for Computer Science, then you need to save using the createWithoutData method. So let's recap: You have a Student table with a column called CourseId - that is a pointer to the Course table, not the CourseId column of the Course table. You can't point to a column, you point to a table.

所以,当你创建一个新的Student对象,你需要一个指针保存到计算机科学的CourseId列。比方说计算机科学对象在你的课程表中的OBJECTID是XYZ123。你会做到以下几点:

So when you create a new Student object, you need to save a pointer into the CourseId column for Computer Science. Let's say the objectID of the Computer Science object in your Course table is "xyz123". You would do the following:

ParseObject student = new ParseObject("Student");
student.put("CourseId", ParseObject.createWithoutData("Course", "xyz123");
//...set other values for the student object
student.saveInBackground();

在解析文档有你需要什么,并更多 - 退房关系数据的部分:
<一href=\"https://parse.com/docs/android_guide#objects-pointers\">https://parse.com/docs/android_guide#objects-pointers

这篇关于解析:如何设置一个指针的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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