populating gridview using layout inflator
<p>I am trying to populate a gridview using LayoutInflator.. According to me the code is correct but I am only getting a blank screen as output... if someone could tell me what am i doing wrong and how to rectify it.. Thanks in advance</p>

<p><strong>Activity class</strong></p>

<pre><code> public class MultipleDocumentViewActivity extends Activity {
   private LayoutInflater inflator = null;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);

           inflator = LayoutInflater.from(getApplicationContext());

           GridView grid = (GridView)inflator.inflate(R.layout.main, null);

           GridAdapter gAdapter = new GridAdapter(this);
           grid.setAdapter(gAdapter);
           setContentView(R.layout.main);


         }
        }
</code></pre>

<p><strong>GridAdapter.java</strong></p>

<pre><code>     public class GridAdapter extends BaseAdapter
      {
     private Context context;
     private LayoutInflater layoutInflator = null;

     private Integer[] mThumbnails =                                                                                                           {R.drawable.kunfu1,R.drawable.kunfu2,R.drawable.kunfu3,R.drawable.kunfu4};

         public GridAdapter(Context c)
           {
          context = c;

          Log.d("Aditi","Constructor called");
           }
           public int getCount() {

         return mThumbnails.length;
           }

           public Object getItem(int position) {

          return null;
           }

           public long getItemId(int position) {

           return 0;
            }

           public View getView(int position, View grid, ViewGroup parent) 
           {
           layoutInflator =          (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

         if(grid == null)
          {
         layoutInflator = LayoutInflater.from(context);



         grid = layoutInflator.inflate(R.layout.mdv_grid_item, null);

          }
          ImageView imageView =  (ImageView)grid.findViewById(R.id.grid_item);

          imageView.setImageResource(mThumbnails[position]);
          imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

          return grid;

          }

          }




     **mdv_grid_item**
</code></pre>

<p>
</p>

<pre><code>&lt;ImageView android:id="@+id/grid_item"
    android:layout_width="fill_parent" android:layout_height="270dp"
    android:contentDescription="@string/desc"&gt;
&lt;/ImageView&gt;
</code></pre>

<p></p>

<pre><code>**main.xml**
    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:horizontalSpacing="20dp" android:numColumns="3"
    android:paddingLeft="40dp" android:paddingRight="40dp"
    android:paddingTop="40dp" android:stretchMode="columnWidth"
    android:verticalSpacing="20dp"
    android:listSelector="#00000000"
    android:id = "@+id/grid"&gt;
       &lt;/GridView&gt;
</code></pre>

<p>Thanks a lot in advance</p>
