2011-05-18 29 views
10

Necesito poder hacer clic en imgview en un listview, que debería abrir una ventana emergente que muestra el tamaño completo de la imagen. Logré implementar el clicklistener, pero sigo fallando al crear el menú emergente, incluso con solo una prueba textview.Ventana emergente con imagen

En mi mainActivity alcrear corro

lstView.setAdapter(new CustomListViewAdapter(this, dataFromDBListe, 0, orientation)); 

En mi CustomListVievAdapter, donde tengo mi clickListener (que puede mostrar un brindis por el momento) Tengo el siguiente getView():

public View getView(int position, View convertView, ViewGroup parent) { 
    ViewHolder holder; 
    if (convertView == null) { 
     convertView = mInflater.inflate(R.layout.custom_row, null); 
     holder = new ViewHolder(); 
     holder.title = (TextView) convertView.findViewById(R.id.title); 
     holder.prev = (TextView) convertView.findViewById(R.id.prevNrDate); 
     holder.prevTitle = (TextView) convertView.findViewById (R.id.prevTitle); 
     holder.next = (TextView) convertView.findViewById(R.id.nextNrDate); 
     holder.nextTitle = (TextView) convertView.findViewById  (R.id.nextTitle); 
     holder.picture = (ImageView) convertView.findViewById (R.id.showPic); 
     holder.prevFast = (TextView) convertView.findViewById(R.id.prev); 
     holder.nextFast = (TextView) convertView.findViewById(R.id.next); 
     holder.linearLayout = (LinearLayout) convertView.findViewById (R.id.imgLay); 
     convertView.setTag(holder); 
    } else { 
     holder = (ViewHolder) convertView.getTag(); 
    } 
    testSort(holder); 
    final Show item = showList.get(position); 
    holder.title.setText(item.getTitle()); 
    holder.prev.setText(item.getPrevNr() + " - " + item.getPrevDate()); 
    holder.prevTitle.setText(item.getPrevTitle()); 
    holder.next.setText(item.getNextNr() + " - " + item.getNextDate()); 
    holder.nextTitle.setText(item.getNextTitle()); 

    if(pic) { 
     holder.linearLayout.setVisibility(8); 
    } if(compact) { 
     holder.linearLayout.setVisibility(8); 
     holder.prevTitle.setVisibility(8); 
     holder.nextTitle.setVisibility(8); 
    } else { 
//   new DownloadImageTask(holder.picture).execute(item.getShowId()); 
     String path; 
     if(ih.checkImg(item.getShowId())) { 
      path = PATH + item.getShowId() + ".jpg"; 
     } else { 
      path = "bla"; 
     } 
//   DrawableManager dm = new DrawableManager(); 
//   dm.fetchDrawableOnThread(path, holder.picture); 
     imageDownloader.download(path, holder.picture); 
//   ih.download(path, holder.picture); 
    } 

    holder.picture.setOnClickListener(new View.OnClickListener() { 
       public void onClick(View view) { 
        Toast.makeText(context, "IMG clicked", 
          Toast.LENGTH_LONG).show(); 
        //Show popup with full image of the clicked small img. 
       } 
      }); 

    return convertView; 
} 

I intenté la mayoría de las soluciones comúnmente enlazadas aquí para popupwindow, pero no puedo hacerlo funcionar.

Respuesta

28

Crear medida de diálogo y pasar la imagen en ella ....

private void loadPhoto(ImageView imageView, int width, int height) { 

     ImageView tempImageView = imageView; 


     AlertDialog.Builder imageDialog = new AlertDialog.Builder(this); 
     LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); 

     View layout = inflater.inflate(R.layout.custom_fullimage_dialog, 
       (ViewGroup) findViewById(R.id.layout_root)); 
     ImageView image = (ImageView) layout.findViewById(R.id.fullimage); 
     image.setImageDrawable(tempImageView.getDrawable()); 
     imageDialog.setView(layout); 
     imageDialog.setPositiveButton(resources.getString(R.string.ok_button), new DialogInterface.OnClickListener(){ 

      public void onClick(DialogInterface dialog, int which) { 
       dialog.dismiss(); 
      } 

     }); 


     imageDialog.create(); 
     imageDialog.show();  
    } 

custom_fullimage_dialog.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout_root" android:orientation="horizontal" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:padding="10dp"> 
    <ImageView android:id="@+id/fullimage" android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    </ImageView> 

    <TextView android:id="@+id/custom_fullimage_placename" 
     android:layout_width="wrap_content" android:layout_height="fill_parent" 
     android:textColor="#FFF"> 
    </TextView> 
</LinearLayout> 
+0

Esto funcionó a la perfección. Gracias. – Crunch

+0

@Crunch: ur WC :), si tienes solución estás buscando tben amablemente vote – Zoombie

+0

@Zoombie en Whatsapp cuando se muestra listview con contactos que cuando hago clic en la imagen del contacto particular (Profile pic) la ventana emergente se abre desde allí donde se toca y ciérrelo allí. Entonces, ¿qué animación han usado para lo mismo? – Swift

Cuestiones relacionadas