2016-01-04 42 views
0
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(); 
     } 
    } 
}); 

我怎麼可以讓我搜吧??用戶名的「用戶名」,這樣我就可以在之前TY mainActivity舉杯吧。我被困在這裏。 請幫助我如何得到解析的Android

+0

對象的類型ParseUser的名單我不知道讓ParseUser如果你想用就可以了toString方法 – g90

回答

0

使用用戶名

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(); 
     } 

    } 
});