title: How to create a popup window programmatically in Android
body: <p>I have made Activity which will popup on click of button. I have to add listener on Image Button. I have made the design in XMl but I want to design programmatically. </p>
  
  <p>This is my image of xml design. </p>
  
  <p><a href="https://i.stack.imgur.com/oPTR0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oPTR0.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".PopupMenu"&gt;
      &lt;GridLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:columnCount="4"
          android:orientation="horizontal"
          android:rowCount="1"&gt;
          &lt;ImageView
              android:id="@+id/imageOnlineIcon"
              android:layout_width="28dp"
              android:layout_height="28dp"
              app:srcCompat="@drawable/olnine_user"
              android:layout_row="0"
              android:layout_column="0" /&gt;
          &lt;TextView
              android:id="@+id/textViewUserName"
              android:layout_width="201dp"
              android:layout_height="44dp"
              android:text="Shyam"
              android:textAlignment="center"
              android:textSize="22sp" /&gt;
          &lt;ImageButton
              android:id="@+id/imageVideoIcon"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/videonline" /&gt;
          &lt;ImageButton
              android:id="@+id/imageMuteIcon"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/muted" /&gt;
      &lt;/GridLayout&gt;
      &lt;View style="@style/Divider"/&gt;
      &lt;GridLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:columnCount="4"
          android:orientation="horizontal"
          android:rowCount="1"&gt;
          &lt;ImageView
              android:id="@+id/imageOnlineIcon1"
              android:layout_width="28dp"
              android:layout_height="28dp"
              app:srcCompat="@drawable/olnine_user" /&gt;
          &lt;TextView
              android:id="@+id/textViewUserName1"
              android:layout_width="201dp"
              android:layout_height="44dp"
              android:text="Samir"
              android:textAlignment="center"
              android:textSize="22sp" /&gt;
          &lt;ImageButton
              android:id="@+id/imageVideoIcon1"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/videonline" /&gt;
          &lt;ImageButton
              android:id="@+id/imageMuteIcon1"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/muted" /&gt;
      &lt;/GridLayout&gt;
      &lt;View style="@style/Divider"/&gt;
      &lt;GridLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:columnCount="4"
          android:orientation="horizontal"
          android:rowCount="1"&gt;
          &lt;ImageView
              android:id="@+id/imageOnlineIcon2"
              android:layout_width="28dp"
              android:layout_height="28dp"
              app:srcCompat="@drawable/olnine_user" /&gt;
          &lt;TextView
              android:id="@+id/textViewUserName2"
              android:layout_width="201dp"
              android:layout_height="44dp"
              android:text="Vivek"
              android:textAlignment="center"
              android:textSize="22sp" /&gt;
          &lt;ImageButton
              android:id="@+id/imageVideoIcon2"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/videonline" /&gt;
          &lt;ImageButton
              android:id="@+id/imageMuteIcon2"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@drawable/muted" /&gt;
      &lt;/GridLayout&gt;
      &lt;View style="@style/Divider"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I have to create the same design in java programatically. And Add the listener in Image Button so that i can handle the button.</p>