title: Adding GridView in Fragment
body: <p>Here is my code for getting GridView:</p>
  
  <pre><code>public class MoviesFragment extends Fragment {
  
  
  AppController instance = AppController.getInstance();
  List&lt;Movie&gt; movies = new ArrayList&lt;Movie&gt;();
  String html;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_movies, container, false);
  
      GridView gridView;
          gridView = (GridView) rootView.findViewById(R.layout.fragment_movies);
          movies = getMoviesList();
          gridView.setAdapter(new MoviesAdapter(getActivity(), movies));
  
      return rootView;
  }
  
  public List&lt;Movie&gt; getMoviesList()
  {
      List&lt;Movie&gt; movies = new ArrayList&lt;Movie&gt;();
  
      try {
          org.jsoup.nodes.Document doc = Jsoup.parse(getActivity().getAssets().open("site.html"), "UTF-8", "");
          Elements get = doc.select("div.post.lit &gt; h2");
          for (Element element : get) 
          {
              movies.add(new Movie(element.text()));
          }
      } catch (IOException e) {
          // TODO Auto-generated catch block
      }
  
      System.out.println(movies.size());
  
      return movies;
  }
  
  
  }
  </code></pre>
  
  <p>and here is my <code>MovieAdapter</code> class for items in gridView:</p>
  
  <pre><code>public class MoviesAdapter extends ArrayAdapter&lt;Movie&gt;
  {
  
  
  List&lt;Movie&gt; moviesList;
  Context context;
  
  public MoviesAdapter(Context context, List&lt;Movie&gt; objects) 
  {
      super(context, android.R.id.content, objects);
      this.moviesList = objects;
      this.context = context;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) 
  {
      LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
      View view = layoutInflater.inflate(R.layout.fragment_movies_individual, parent);
      TextView name = (TextView) view.findViewById(R.id.textView1);
      TextView description = (TextView) view.findViewById(R.id.textView2);
      name.setText(moviesList.get(position).getName());
      description.setText(moviesList.get(position).getDescription());
      return view;
  }
  }
  </code></pre>
  
  <p>when I run the app, it just keep crashing and throwing <code>NullPointerException</code> in the line of setting adapter for gridView.(<code>gridView.setAdapter(new MoviesAdapter(getActivity(), movies));</code>
  I checked movieList items and it's populated properly.</p>
  
  <p>what is wrong here?</p>