私はこの1つに非常に近いと感じています。最後のビットが必要です。Android Parse - 他のテーブルへのポインタのテーブル、他のテーブルのオブジェクトを取得したい
I持って以下の表:
_User(標準の解析テーブル)
カテゴリ(オブジェクトID、名前)
演習(オブジェクトID、名前、説明、サムネイル、画像、など)
私は、ユーザーの好みの演習(OBJECTID、USER->ユーザテーブル、エクササイズ> exerciの保管場所である
とUserFavourites SESテーブル、category->カテゴリ表)
私はちょうど良いのポインタを使用して解析するために書いている:
//create new parse object
ParseObject favouriteExercise = new ParseObject("UserFavourites");
//create pointers to the Exercise table and Category table
ParseObject exercise = ParseObject.createWithoutData("Exercises", mExerciseId);
ParseObject category = ParseObject.createWithoutData("Category", mCategoryId);
//put those pointers into the Userfavourites table and save
favouriteExercise.put("user",ParseUser.getCurrentUser());
favouriteExercise.put("exercise",exercise);
favouriteExercise.put("category",category);
//save
favouriteExercise.saveInBackground();
は今、私は、ユーザーお気に入り化(favourited)しているすべての演習を取得しにに入れしようとしていますユーザーの表に、ユーザのポインタに一致するすべてのオブジェクトのためのテーブルを検索してリストビュー: - >私は4行を取得しています、私はこだわっている
ParseQuery<Exercises> query = ParseQuery.getQuery("UserFavourites");
final ParseObject user = ParseObject.createWithoutData(ParseUser.class, ParseUser.getCurrentUser().getObjectId());
query.whereEqualTo("user", user);
//call to parse.com to start the query
query.findInBackground(new FindCallback<Exercises>() {
@Override
public void done(List<Exercises> exercises, ParseException e) {
if (exercises != null) {
Toast.makeText(getApplicationContext(), "Favourites found, can't list yet", Toast.LENGTH_SHORT).show();
mAdapter.clear();
//add all the exercises to the list
mAdapter.addAll(exercises);
//sort the list alphabetically
mAdapter.sort(new Comparator<Exercises>() {
@Override
public int compare(Exercises exercises, Exercises t1) {
return exercises.getName().compareTo(t1.getName());
}
});
} else {
mNoFavourites.setVisibility(View.VISIBLE);
}
がある私は、私は私のクエリが働いている見ることができ、これを実行するとUserFavouritesでは、私が8の表の中から好きなので、それはフィルタリングcorrですしかし、私が得ているオブジェクトは、私が望むエクササイズを指していません。それらは単に空のポインタです。
ありがとうございました。
ありがとうございます、この種の助けはありましたが、問題をかなり修正していませんでした。 –