我创建了一个使用parse作为我的后端的Android应用程序。
当我查询这样的用户时
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereMatches("username", name);
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (e == null) {
if (!objects.isEmpty()) { show.setText(objects.size());}
else {show.setText("No Tuples");}
for (ParseUser singleobject : objects) {
mail[i] = singleobject.get("email").toString();
uname[i] = singleobject.get("username").toString();
i++;
}
} else {
show.setText("NO Success");
}}});
当我尝试运行此代码时,出现以下错误
Process: com.example.nirmal.sportsparse, PID: 10491
android.content.res.Resources$NotFoundException: String resource ID #0x1
at android.content.res.Resources.getText(Resources.java:254)
at android.widget.TextView.setText(TextView.java:3925)
at com.example.nirmal.sportsparse.search_players$1.done(search_players.java:68)
at com.example.nirmal.sportsparse.search_players$1.done(search_players.java:64)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:115)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
错误指向我使用objects.size()和findInBackground调用的行。
当我删除objects.size()时,调用函数正常工作并检索所有必需的元组。
这背后的原因是什么?
答案 0 :(得分:1)
而不是
show.setText(objects.size())
应该是
show.setText(String.valueOf(objects.size()));