title: Display image in popout window after button is clicked -- Android/Java
body: <p>I've been searching the internet for a solution to this problem for several hours now and I can't seem to find an answer that works.
  I have written an android app that uses the camera emulator in Eclipse to take a photo and save it to the sd card (path is stored using a String called "file"). What I would like to do is display the image, preferably in a sort of pop-out window, with another button that closes it and returns to the app. I expect I'll need to create another class to do this, but I am not sure all that is involved. Will I have to create another XML file to do the layout? How could I access the file and display it? I expect I'll use ImageView if I am to use another class, but other than that I'm not sure what to do. 
  There's not much code I can really provide that would help, other than the method which is called when the button is clicked. This part of the code works just fine, and it's simply a method that looks like this:</p>
  
  <pre><code>public void viewPhoto(file){ }
  </code></pre>
  
  <p>As you can see, I have nothing inside the method yet, that is why I am posting here.
  I have been trying to figure this out for several hours, so I would greatly appreciate any ideas you folks might have.</p>
  
  <p><strong>EDIT: MORE INFO</strong></p>
  
  <p>Many of the suggestions I have found require the image to be stored in the "src" folder of the project. However, this photo will be taken and used all within the same program, so I'll have to be able to access it using its file path alone. I can't just state its location in the XML. I created a Dialog object within my existing code, but I'm not sure if this will work. The dialog I plan to use should be able to access the photo from the specified path that is stored in the string mentioned before.</p>
  
  <p>I have been referring to the first answer in this thread: <a href="https://stackoverflow.com/questions/7693633/android-image-dialog-popup">Android Image Dialog/Popup</a>
  but as you can see it requires the image to be in the src folder and specified in the XML. </p>
  
  <p><strong>SECOND EDIT:</strong></p>
  
  <p>Here is the code I currently have, both for the XML and the Java. But first I want to mention that I have two XML files--one called activity_main.xml which handles all the initial buttons, menu, etc. The second one is only for my photo (called photo_viewer.xml) and it only contains the ImageView.</p>
  
  <p>photo_viewer.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/pictureViewer"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:contentDescription="@string/viewImage" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Java method to generate image:</p>
  
  <pre><code>public void viewPhoto(String file){ 
      ImageView imageView = new ImageView(getApplicationContext());
      LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT);
      Bitmap image = BitmapFactory.decodeFile(file);
      imageView.setImageBitmap(image);
      RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictureViewer);
      rl.addView(imageView, lp);
  }
  </code></pre>