我正在尝试根据facebook-android-sdk中的示例实现一个 facebook 应用程序。我正在对其进行一些更改,但我对某些非常基本的东西感到困难。
我的主要活动显示了我附近的 facebook 位置。这就是 mainActivity.java 中的代码
private void getFBPlaces()
{
fbObject.fetchPlaces();
// NOW I want to fill my listview with the results.....
// someting like
placesList = (ListView) findViewById(R.id.places_list);
placesList.setOnItemClickListener(Places.this);
placesList.setAdapter(new PlacesListAdapter(Places.this));
}
这是来自 FBObject.java 的相关代码,请参阅 TODO
private void fetchPlaces() {
/*
* Source tag: fetch_places_tag
*/
Bundle params = new Bundle();
params.putString("type", "place");
try {
params.putString("center",
location.getString("latitude") + "," + location.getString("longitude"));
} catch (JSONException e) {
showToast("No places fetched.");
return;
}
params.putString("distance", "1000");
Utility.mAsyncRunner.request("search", params, new placesRequestListener());
}
/*
* Callback after places are fetched.
*/
public class placesRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
Log.d("Facebook-FbAPIs", "Got response: " + response);
dialog.dismiss();
try {
jsonArray = new JSONObject(response).getJSONArray("data");
if (jsonArray == null) {
showToast("Error: nearby places could not be fetched");
return;
}
} catch (JSONException e) {
showToast("Error: " + e.getMessage());
return;
}
mHandler.post(new Runnable() {
@Override
public void run() {
// TODO: I want to return the result to main activity
.....
}
});
}
有什么想法吗?谢谢