title: Android Grid View with Custom base Adapter
body: <p>i have started to learn android development. i am making an app in which i want to show movie thumbnails(image view and text view) combined in grid view layout i have made custom adapter but problem is that i cannot figure it out how to show image view and text view together.when i run app it shows blank white screen. i have tried many solution and also googled a lot but i cannot figure it out how to do this please help me. Here is my code. </p>
  
  <pre><code>    public class ImageAdapter extends BaseAdapter {
  
      private Context mContext;
      private LayoutInflater inflater;
      public ImageAdapter(Context c) {
  
          mContext = c;
        //
      }
  
      @Override
      public int getCount() {
          return mThumbIds.length;
      }
  
      @Override
      public Object getItem(int i) {
          return null;
      }
  
      @Override
      public long getItemId(int i) {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup viewGroup) {
  
  
          NewHolder holder = null;
          ImageView imageView;
  
          inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
  
  
  
          if(convertView==null){
              holder = new NewHolder();
  
              convertView =inflater.inflate(R.layout.activity_main,viewGroup,false);
  
  
              holder.imageView = new ImageView(mContext);
              holder.textView = new TextView(mContext);
  
              holder.imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
              holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
  
  
  
           //   holder.textView.setLayoutParams(new GridView.LayoutParams(85, 85));
  
              convertView.setTag(holder);
              //textView.
             // textView.setText("Hello");
              holder.imageView.setPadding(8, 8, 8, 8);
  
          }
  
  
          else {
              holder = (NewHolder) convertView.getTag();
              //imageView= (ImageView) convertView. ;
              //textView = (TextView) convertView;
          }
  
  
  //        convertView.
          holder.imageView.setImageResource(mThumbIds[position]);
       //   holder.textView.setText("hello");
          return convertView;
  
  
  
      }
  
  
  
      private Integer[] mThumbIds = {
              R.drawable.sample_2, R.drawable.sample_3,
              R.drawable.sample_4, R.drawable.sample_5,
              R.drawable.sample_6, R.drawable.sample_7,
              R.drawable.sample_0, R.drawable.sample_1,
              R.drawable.sample_2, R.drawable.sample_3,
              R.drawable.sample_4, R.drawable.sample_5,
              R.drawable.sample_6, R.drawable.sample_7,
              R.drawable.sample_0, R.drawable.sample_1,
              R.drawable.sample_2, R.drawable.sample_3,
              R.drawable.sample_4, R.drawable.sample_5,
              R.drawable.sample_6, R.drawable.sample_7
      };
  
  }
  </code></pre>
  
  <p>Main Activity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          GridView gridview = (GridView) findViewById(R.id.grid_view);
          gridview.setAdapter(new ImageAdapter(this));
       //   setContentView(gridview);
  
      }
  </code></pre>
  
  <p>Holder Class</p>
  
  <pre><code>public class NewHolder {
  
          public ImageView imageView;
          public TextView textView;
      }
  </code></pre>
  
  <p>Main Xml Layout File</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/grid_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:columnWidth="90dp"
      android:numColumns="auto_fit"
      android:verticalSpacing="10dp"
      android:horizontalSpacing="10dp"
      android:stretchMode="columnWidth"
      android:gravity="center"
      /&gt;
  </code></pre>