How to bind data in gridview found in fragment in android app?
<p>I have a fragment class and its layout is in xml. Inside the xml fragment layout is the gridview. I wanted the gridview to show the data.</p>

<p>What happens is that when I run the android app, the app failed to execute/run. It has stopped unexpectedly.</p>

<pre><code>public class FrontPageFragment extends Fragment {

//private ArrayAdapter adapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    final String [] items=new String[]{"Item1","Item2","Item3","Item4"};
    ArrayAdapter ad=new ArrayAdapter&lt;String&gt;(this.getActivity().getApplicationContext(),R.layout.frontpage,items);

    View fragmentView=getView();    
    GridView grid=(GridView)fragmentView.findViewById(R.id.forApprovalOrders);
    grid.setAdapter(ad);

    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.frontpage, container, false);

}
</code></pre>

<p>=========================================================================</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;

    &lt;GridView android:id="@+id/forApprovalOrders" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:columnWidth="90dp"
                android:numColumns="auto_fit"
                android:verticalSpacing="10dp"
                android:horizontalSpacing="10dp"
                android:stretchMode="columnWidth"
                android:gravity="center"
    &gt;
    &lt;/GridView&gt;

    &lt;ExpandableListView android:id="@+id/sampleExpandable" android:layout_height="wrap_content" android:layout_width="match_parent"&gt;&lt;/ExpandableListView&gt;


&lt;/LinearLayout&gt;
</code></pre>
