final String username = ETsearch.getText().toString();
final ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereEqualTo("username", username);
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> objects, com.parse.ParseException e) {
if (e == null) {
if (objects.size() > 0) {
//String usernameCari = objects.get(objects.size()).getUsername();
//objects.get(1).getUsername();
Toast.makeText(getApplicationContext(), "Username Found "+objects.toString(),
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Username Not Found",
Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getApplicationContext(), "EROR",
Toast.LENGTH_LONG).show();
}
}
});
我怎么能得到一个我搜索它的用户名?所以我可以在之前的mainActivity ty中干它。我被困在这里。 请帮忙
答案 0 :(得分:0)
使用用户名
获取ParseUser
final ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereEqualTo("username", username);
query.getFirstInBackground(new GetCallback<ParseUser>() {
@Override
public void done(ParseUser parseUser, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
String userName = parseUser.getUsername();
String email = parseUser.getEmail();
} else {
Toast.makeText(getApplicationContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
});