title: Cannot set adapter in onComplete method Facebook SDK, ANDROID
body: <p><strong>I cannot set an adapter to my GridView called "lista". This is my Activity:</strong></p>
  
  <pre><code>public class ListaAmigos extends Activity {
  
  private String TAG = "ListaAmigos";
  protected static Context context;
  private GridView lista;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.lista_amigos);
      context = getApplicationContext();
  
      lista = (GridView) findViewById(R.layout.lista_amigos);
  
      Session session = Session.getActiveSession();
  
      if (session != null &amp;&amp; session.isOpened()) {
          facebookRequest(session);
      }
  
  }
  
  private void facebookRequest(Session session) {
      Request friendsRequest = createRequest(session);
      RequestAsyncTask requestAsync = new RequestAsyncTask(friendsRequest);
      requestAsync.execute();
  
      friendsRequest.setCallback(new Request.Callback() {
          @Override
          public void onCompleted(Response response) {
              List&lt;GraphUser&gt; friends = getResults(response);
  
              ListarAmigosAdapter adapter = new ListarAmigosAdapter(context,
                      friends);
  
              lista.setAdapter(adapter);
  
          }
  
      });
  }
  
  private Request createRequest(Session session) {
      Request request = Request.newGraphPathRequest(session, "me/friends",
              null);
  
      Set&lt;String&gt; fields = new HashSet&lt;String&gt;();
      String[] requiredFields = new String[] { "id", "name",
              "picture.type(large)" };
      fields.addAll(Arrays.asList(requiredFields));
  
      Bundle parameters = request.getParameters();
      parameters.putString("fields", TextUtils.join(",", fields));
      request.setParameters(parameters);
  
      return request;
  }
  
  private List&lt;GraphUser&gt; getResults(Response response) {
      GraphMultiResult multiResult = response
              .getGraphObjectAs(GraphMultiResult.class);
      GraphObjectList&lt;GraphObject&gt; data = multiResult.getData();
      return data.castToListOf(GraphUser.class);
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p><strong>And my adapter:</strong></p>
  
  <pre><code>public class ListarAmigosAdapter extends BaseAdapter {
  
  private List&lt;GraphUser&gt; friends;
  private BitmapLruCache imageCache;
  private Context context;
  
  public ListarAmigosAdapter(Context context, List&lt;GraphUser&gt; friends) {
      this.friends = friends;
      this.context = context;
      imageCache = new BitmapLruCache();
  }
  
  public int getCount() {
      return friends.size();
  }
  
  public GraphUser getItem(int position) {
      return friends.get(position);
  }
  
  public long getItemId(int position) {
      return Long.parseLong(friends.get(position).getId());
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View itemView = convertView;
      ViewHolder holder = null;
      if (convertView == null) {
          LayoutInflater inflater = LayoutInflater.from(ListaAmigos.context);
          convertView = inflater.inflate(R.layout.un_amigo, null);
  
          holder = new ViewHolder();
  
          holder.mRequestQueue = Volley.newRequestQueue(ListaAmigos.context);
          holder.imageLoader = new ImageLoader(holder.mRequestQueue,
                  imageCache);
  
          holder.position = position;
          holder.foto = (NetworkImageView) convertView
                  .findViewById(R.id.imagen);
          holder.nombre = (TextView) convertView.findViewById(R.id.nombre);
          convertView.setTag(holder);
      }
  
      JSONObject friendsJSON = friends.get(position).getInnerJSONObject();
  
      try {
          holder.nombre.setText(friendsJSON.getString("name"));
  
      } catch (JSONException e) {
          Log.d("JSON error " + e.getMessage(), "ERROR JSON");
      }
  
      return itemView;
  }
  
  static class ViewHolder {
      ImageLoader imageLoader;
      RequestQueue mRequestQueue;
      NetworkImageView foto;
      TextView nombre;
      int position;
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p><strong>And the error:</strong></p>
  
  <pre><code>02-18 19:27:02.561: E/AndroidRuntime(25109): FATAL EXCEPTION: main
  02-18 19:27:02.561: E/AndroidRuntime(25109): java.lang.NullPointerException
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at com.ardroid.fav.lista_amigos.ListaAmigos$1.onCompleted(ListaAmigos.java:59)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at com.facebook.Request$4.run(Request.java:1669)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at android.os.Handler.handleCallback(Handler.java:615)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at android.os.Handler.dispatchMessage(Handler.java:92)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at android.os.Looper.loop(Looper.java:137)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at android.app.ActivityThread.main(ActivityThread.java:4867)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at java.lang.reflect.Method.invokeNative(Native Method)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at java.lang.reflect.Method.invoke(Method.java:511)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
  02-18 19:27:02.561: E/AndroidRuntime(25109):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>