title: Use alert dialog or custom dialog to show custom gridview
body: <p>I just want to show this custom <code>GridView</code> in a <code>AlertDialog</code> box.
  But I just don't have any idea for how do this.
  My GridView custom is:</p>
  
  <h3>MyActivity:</h3>
  
  <pre><code>public class MyActivity extends Activity{
      private GridviewAdapter mAdapter;
      private ArrayList&lt;String&gt; taxtVlue;
      private ArrayList&lt;Integer&gt; imageValue;
      private DisplayMetrics metrics;
  
      private GridView gridView;
      public TextView txtViewTitle;
      public Typeface tp;
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
          //prepareing list
          taxtVlue=GridViewValues.taxtVlue();
          imageValue=GridViewValues.imageValue();
  
          metrics = new DisplayMetrics();
  
          getWindowManager().getDefaultDisplay().getMetrics(metrics);
          // prepared arraylist and passed it to the Adapter class
  
          mAdapter = new GridviewAdapter(this,taxtVlue, imageValue, metrics );
  
          // Set custom adapter to gridview
  
  
  
      }
  </code></pre>
  
  <h3>GridviewAdapter.java:</h3>
  
  <pre><code>public class GridviewAdapter extends BaseAdapter {
      private ArrayList&lt;String&gt; listCountry;
      private ArrayList&lt;Integer&gt; listFlag;
      private Activity activity;
      private DisplayMetrics metrics_;
  
      public GridviewAdapter(Activity activity, ArrayList&lt;String&gt; listCountry, ArrayList&lt;Integer&gt; listFlag, DisplayMetrics metrics) {
          super();
          this.listCountry = listCountry;
          this.listFlag = listFlag;
          this.activity = activity;
          this.metrics_ = metrics;
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return listCountry.size();
      }
  
      @Override
      public String getItem(int position) {
          // TODO Auto-generated method stub
          return listCountry.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return 0;
      }
  
      public static class ViewHolder {
          public ImageView imgViewFlag;
          public TextView txtViewTitle;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          ViewHolder view;
          LayoutInflater inflator = activity.getLayoutInflater();
  
          if (convertView == null) {
              view = new ViewHolder();
              convertView = inflator.inflate(R.layout.gridview_row, null);
  
              view.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
              view.imgViewFlag = (ImageView) convertView.findViewById(R.id.imageView1);
  
              convertView.setTag(view);
          } else {
              view = (ViewHolder) convertView.getTag();
          }
          Animation animation = null;
          //animation = new TranslateAnimation(metrics_.widthPixels / 2, 0, 0, 0);
          animation = AnimationUtils.loadAnimation(activity.getBaseContext(), R.anim.push_up_in);
  
          animation.setDuration(500);
          convertView.startAnimation(animation);
  
          view.txtViewTitle.setText(listCountry.get(position));
          view.imgViewFlag.setImageResource(listFlag.get(position));
  
  
          return convertView;
      }
  }
  
  }
  </code></pre>
  
  <p>I just want when user click on some thing a AlertDialog or any kind of Dialog pops up and my GridView shows inside the dialog box. In other words I just want to create some thing like this:</p>
  
  <pre><code>private void showAlertDialog() {
      // Prepare grid view
      GridView gridView = new GridView(this);
  
      List&lt;Integer&gt;  mList = new ArrayList&lt;Integer&gt;();
      for (int i = 1; i &lt; 36; i++) {
          mList.add(i);
      }
  
      gridView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, mList));
      gridView.setNumColumns(5);
      gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              // do something here
          }
      });
  
      // Set grid view to alertDialog
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setView(gridView);
      builder.setTitle("Goto");
      builder.show();
  }
  </code></pre>
  
  <p>But because I've used custom GridView I don't know how use it inside an AlertDialog.</p>