我正在尝试使用地址填充列表视图,方法是在附近的位置运行查询,从点g到解析服务器中的地址/ geopoint列表。:
public class Map_Masti extends FragmentActivity {
ParseGeoPoint g;
private SupportMapFragment mapFragment;
private TextView textView;
private ParseQueryAdapter<Rahees> adapter;
private ParseQueryAdapter<Rahees> postsQueryAdapter;//this is outside oncreate
private List <ParseGeoPoint> points=new ArrayList<ParseGeoPoint>();
private void getG() {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground("ccm3xKMmr4", new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
if (e == null) {
g = (ParseGeoPoint) object.get("user_Location");
display();
} else {
}
}
});
}
public void display()
{
// Set up a customized query
ParseQueryAdapter.QueryFactory<Rahees> factory =
new ParseQueryAdapter.QueryFactory<Rahees>() {
public ParseQuery<Rahees> create() {
ParseQuery<Rahees> query = Rahees.getQuery();
query.include("user");
query.whereWithinKilometers("Locations", g, 1000);
query.findInBackground(new FindCallback<Rahees>() {//here is the error
@Override
public void done(List<Rahees> objects, ParseException e) {
//to check if there is a result
}
}
});
return query;
}
};
// Set up the query adapter
postsQueryAdapter = new ParseQueryAdapter<Rahees>(this, factory) {
@Override
public View getItemView(Rahees post, View view, ViewGroup parent) {
if (view == null) {
view = View.inflate(getContext(), R.layout.row1_of_listvew, null);
}
TextView contentView = (TextView) view.findViewById(R.id.textView1);
TextView usernameView = (TextView) view.findViewById(R.id.textView2);
contentView.setText(post.getInt("Address"));
usernameView.setText(post.getInt("Address"));
return view;
}
};
postsQueryAdapter.setAutoload(false);
// ***************************Disable pagination, we'll manage the query limit ourselves********************************/
postsQueryAdapter.setPaginationEnabled(false);
//********************************** Attach the query adapter to the view/
ListView postsListView = (ListView) findViewById(R.id.listview);
postsListView.setAdapter(postsQueryAdapter);
postsQueryAdapter.loadObjects();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView = (TextView) findViewById(R.id.text);
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
getG();
}
}
//****************************************************************************//
以下是我得到的错误
01-17 12:35:11.434: E/AndroidRuntime(21497): FATAL EXCEPTION: main
01-17 12:35:11.434: E/AndroidRuntime(21497): Process: in.easyway2.com.learn_parse, PID: 21497
01-17 12:35:11.434: E/AndroidRuntime(21497): java.lang.RuntimeException: This query has an outstanding network connection. You have to wait until it's done.
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQuery.checkIfRunning(ParseQuery.java:948)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQuery.doWithRunningCheck(ParseQuery.java:1129)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQuery.findAsync(ParseQuery.java:1193)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQuery.findInBackground(ParseQuery.java:1180)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQueryAdapter.loadObjects(ParseQueryAdapter.java:387)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.parse.ParseQueryAdapter.loadObjects(ParseQueryAdapter.java:362)
01-17 12:35:11.434: E/AndroidRuntime(21497): at in.easyway2.com.learn_parse.Map_Masti.display(Map_Masti.java:177)
01-17 12:35:11.434: E/AndroidRuntime(21497): at in.easyway2.com.learn_parse.Map_Masti$1.done(Map_Masti.java:50)
01-17 12:35:11.434: E/AndroidRuntime(21497): at in.easyway2.com.learn_parse.Map_Masti$1.done(Map_Masti.java:45)
01-17 12:35:11.434: E/AndroidRuntime(21497): at android.os.Handler.handleCallback(Handler.java:733)
01-17 12:35:11.434: E/AndroidRuntime(21497): at android.os.Looper.loop(Looper.java:136)
01-17 12:35:11.434: E/AndroidRuntime(21497): at android.app.ActivityThread.main(ActivityThread.java:5001)
01-17 12:35:11.434: E/AndroidRuntime(21497): at java.lang.reflect.Method.invoke(Method.java:515)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-17 12:35:11.434: E/AndroidRuntime(21497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-17 12:35:11.434: E/AndroidRuntime(21497): at dalvik.system.NativeStart.main(Native Method)
Parse的新手,所以不太确定,只是按照指南中的说明进行操作。
答案 0 :(得分:0)
您应该尝试再次卸载并重新安装该应用。这至少解决了我的问题。
您可以尝试的另一件事是删除并重新创建您要查询的对象或类。
告诉我这是否有效。
答案 1 :(得分:0)
我不应该在工厂查询中添加查询的执行,下面的部分:query.findInBackground(new FindCallback(){//这里是错误@Override public void done(List objects,ParseException e){//检查是否有结果}}});