I am looping through data in Android, using Parse data. I came up with this as a way to get user information; the larger goal is to create a model of data that I can use in an array adapter, so I can create a custom list view (as described here) In the example, the data are hard-coded, not pulled from a database.
public static ArrayList<Midwifefirm> getUsers() {
//Parse data to get users
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByAscending(ParseConstants.KEY_PRACTICE_NAME);
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> users, ParseException e) {
if (e == null) {
final List<ParseUser> mMidwives;
mMidwives = users;
String usertype;
String[] midwives = new String[mMidwives.size()];
String[] yearsofexperience = new String[mMidwives.size()];
String[] education = new String[mMidwives.size()];
String[] philosophy = new String[mMidwives.size()];
int i = 0;
for (ParseUser user : mMidwives) {
usertype = user.getString("userType");
if (!Arrays.asList(midwives).contains(usertype) && usertype != "patient") {
midwives[i] = user.getString("practicename");
yearsofexperience[i] = user.getString("yearsofexperience");
education[i] = user.getString("education");
philosophy[i] = user.getString("practicephilosophy");
ArrayList<Midwifefirm> midwifefirm = new ArrayList<Midwifefirm>();
midwifefirm.add(new Midwifefirm(midwives[i], yearsofexperience[i], education[i], philosophy[i]));
return midwifefirm;
}
}
}
}
});
}
The intention is that for every user that does not have the type patient, collect this data about them, then store it in the arrayList.
On the return statement, though, there is an error: cannot return a value from a method with a void return type.
I may be over complicating this...read through various sources to get a model for this...in the end, I want to display a list of information about specific users, after the user makes a selection of a city...it would therefore display all the information about the medical practices in that city.
Thanks for your help
Michael