コード例 #1
0
 // Show the profile on list item click
 @Override
 public void onListItemClick(ListView l, View v, int position, long id) {
   JSONObject favorite = favoriteAdapter.getItem(position);
   Intent i = new Intent(getActivity(), ProfileViewActivity.class);
   i.putExtra("user_id", favorite.optInt("user_id"));
   startActivity(i);
 }
コード例 #2
0
  // Update our list on a database response
  public void onDatabaseResponse(JSONObject response) {
    // Nothing to do if failed request or not a favorites response
    if (response == null || !response.optBoolean("success")) return;
    if (!response.optString("action").equals("get_favorites")) return;

    try {
      JSONArray resultArray = response.getJSONArray("favorites");

      // Build a list of results and update adapter
      favoriteList.clear();
      for (int i = 0; i < resultArray.length(); i++) {
        favoriteList.add(resultArray.getJSONObject(i));
      }
      favoriteAdapter.notifyDataSetChanged();
    } catch (JSONException e) {
      Log.e(TAG, e.toString(), e);
    }
  }