I have added a relation in an ParseObject which relate to Users, and I would like populate the list of Users who have been added to the relation on an listview. this is what i have so far.
protected List<ParseUser> mCustomers;
ParseObject shopinfo= new ParseObject("Shopinfo");
// get the object from parse
ParseRelation<ParseUser> mCustomerRelation = shopinfo.getRelation(ParseConstants.KEY_CUSTOMER_RELATION);
mCustomerRelation.getQuery().findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> customers, ParseException e) {
if(e==null){
mCustomers=customers;
String[] people= new String [mCustomers.size()];
int i=0;
for(ParseUser customer : mCustomers){
people[i]=customer.getusername;
i++;
}
ArrayAdapter<String>adapter=new ArrayAdapter<String>(getListView().getContext(),
android.R.layout.simple_list_item_1,people);
setListAdapter(adapter);
}
else {
AlertDialog.Builder builder = new AlertDialog.Builder(ResepActivity.this);
builder.setMessage(e.getMessage())
.setTitle(R.string.error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
I kept getting "java.lang.IllegalStateException:unable to encode an association with an unsaved ParseObject"