Cuadros de diálogo personalizados para mostrar imagen, texto y setTitle

Tengo un pequeño problema en mi programa. He estado tratando de averiguar qué es lo que me estoy perdiendo. En mi archivo .java, tengo una vista de cuadrícula de imágenes en la que coloco OnItemsClickListener en los elementos de la vista de cuadrícula. Tengo 2 archivos xml, uno para .java y el otro está configurado como vista de contenido en una ventana emergente al hacer clic en cualquiera de los elementos de la vista de cuadrícula. Quiero que cuando el usuario haga clic en el elemento de la vista de cuadrícula, aparezca el cuadro de diálogo personalizado para mostrar la imagen pulsada, además de una breve descripción de la imagen.

Hasta ahora, el cuadro de diálogo aparece bastante bien, pero no se pasan detalles a este cuadro de diálogo.

Este es mi código activity_first.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    >

<GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:numColumns="3" 
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:columnWidth="90dp"
    android:gravity="center" >

</GridView>

</LinearLayout>

Este es mi archivo activity_custom_dialog.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background">
    <TableLayout    
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <!-- 2 columns -->
        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp" />
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge" />

        </TableRow>

        <!-- Button span 2 column -->
        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip" >

    <Button
                android:id="@+id/button1"
                android:text="Ok" />
        </TableRow>
    </TableLayout>

</LinearLayout>

Finalmente, así es como se ve mi archivo Image.Java:

package com.example.custom;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;


public class ImageActivity extends Activity {
    // Images to display
    Integer[] imageIDs = {
            R.drawable.firefighter,     R.drawable.hydrant,
            R.drawable.fire,            R.drawable.hose,
            R.drawable.truck,           R.drawable.ladder,
            R.drawable.safety_clothing, R.drawable.gloves,
    };
    /**
     * onCreate
     *
     * Called when the activity is first created. 
     * This is where you should do all of your normal static set up: create views, bind data to lists, etc. 
     * This method also provides you with a Bundle containing the activity's previously frozen state, if there was one.
     * 
     * Always followed by onStart().
     *
     * @param savedInstanceState Bundle
     */

    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        setContentView (R.layout.activity_first);
        setTitleFromActivityLabel (R.id.title_text);

        GridView gridview = (GridView) findViewById(R.id.gridView1);
           gridview.setAdapter(new ImageAdapter(this));

           gridview.setOnItemClickListener(new OnItemClickListener()
           {
               public void onItemClick(AdapterView<?> parent, View v, int position, long id)
               {
                    final Dialog dialog = new Dialog(context);
                    dialog.setContentView(R.layout.activity_custom_dialog);

                   switch(v.getId())
                   {
                   case R.drawable.firefighter:
                        dialog.setTitle("FireFighter");                    
                        TextView text = (TextView) dialog.findViewById(R.id.textView1);
                        text.setText("To insert text...");
                        ImageView image = (ImageView) dialog.findViewById(R.id.imageView1);

                        image.setImageResource(R.drawable.firefighter);
                   break;

                   case R.drawable.hydrant:
                        dialog.setTitle("Hydrant");                    
                        TextView text1 = (TextView) dialog.findViewById(R.id.textView1);
                        text1.setText("To insert text...");
                        ImageView image1 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image1.setImageResource(R.drawable.hydrant);
                   break;
                   case R.drawable.fire:
                        dialog.setTitle("Fire");                       
                        TextView text2 = (TextView) dialog.findViewById(R.id.textView1);
                        text2.setText("To insert text...");
                        ImageView image2 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image2.setImageResource(R.drawable.fire);
                   break;
                   case R.drawable.hose:
                        dialog.setTitle("Hose");                       
                        TextView text3 = (TextView) dialog.findViewById(R.id.textView1);
                        text3.setText("To insert text...");
                        ImageView image3 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image3.setImageResource(R.drawable.hose);
                   break;
                   case R.drawable.truck:
                        dialog.setTitle("Truck");                      
                        TextView text4 = (TextView) dialog.findViewById(R.id.textView1);
                        text4.setText("To insert text...");
                        ImageView image4 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image4.setImageResource(R.drawable.truck);
                   break;
                   case R.drawable.ladder:
                        dialog.setTitle("Ladder");                     
                        TextView text5 = (TextView) dialog.findViewById(R.id.textView1);
                        text5.setText("To insert text...");
                        ImageView image5 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image5.setImageResource(R.drawable.ladder);
                   break;
                   case R.drawable.gloves:
                        dialog.setTitle("Gloves");                     
                        TextView text6 = (TextView) dialog.findViewById(R.id.textView1);
                        text6.setText("To insert text...");
                        ImageView image6 = (ImageView) dialog.findViewById(R.id.imageView1);

                        image6.setImageResource(R.drawable.gloves);
                   break;
                   }

                    // set the custom dialog components - text, image and button

                    Button dialogButton = (Button) dialog.findViewById(R.id.button1);
                    // if button is clicked, close the custom dialog
                    dialogButton.setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            dialog.dismiss();
                        }
                    });

                    dialog.show();
           /*                      Toast.makeText(getBaseContext(), "Pic "+(position+1)+
                                  " selected", Toast.LENGTH_SHORT).show();
*/             }
           });
    }

    public class ImageAdapter extends BaseAdapter
    {
        private Context context;

        public ImageAdapter(Context c)
        {
            context = c;
        }


       // Returns the number of images
        public int getCount(){
         return imageIDs.length;
        }

        // Returns the ID of an item
        public Object getItem(int position) {
            return position;
        }

        // Returns the ID of an item
        public long getItemId(int position){
            return position;
        }

        // Returns an ImageView View
        public View getView(int position, View convertView, ViewGroup parent){
            ImageView imageView;
            if(convertView == null){
                imageView = new ImageView(context);
                imageView.setLayoutParams(new GridView.LayoutParams(100,100));
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView.setPadding(5, 5, 5, 5);
            } 
            else{
                imageView = (ImageView) convertView;
            }

            imageView.setImageResource(imageIDs[position]);
            return imageView;
        }

    }

} // end class

Realmente agradecería que obtuviera una guía lo antes posible sobre cómo solucionar este pequeño problema que mis ojos de programador no pueden ver. :-)

Gracias por adelantado.

Respuestas a la pregunta(0)

Su respuesta a la pregunta