title: Disabling background layouts when clicking a button in android
body: <p>I have two List-views and a button in my XML.On clicking the button a popup box will appear.So i want to disable the underlying layouts when button is clicked.How can i do that ?</p>
  
  <p><strong>Here is my xml.</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      android:id="@+id/main_layout"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:background="#25232c"
      android:layout_height="fill_parent"&gt;
  
      &lt;Button
          android:id="@+id/show_popup"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Button" /&gt;
  
      &lt;ListView
          android:id="@+id/list1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" 
          android:layout_weight="1"&gt;
      &lt;/ListView&gt;
  
      &lt;ListView
          android:id="@+id/list2"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" 
          android:layout_weight="1"&gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is my code for popup box</p>
  
  <pre><code>// Get the x and y position after the button is draw on screen
  
      @Override
      public void onWindowFocusChanged(boolean hasFocus) {
  
         int[] location = new int[2];
         Button button = (Button) findViewById(R.id.show_popup);
  
         // Get the x, y location and store it in the location[] array
         // location[0] = x, location[1] = y.
         button.getLocationOnScreen(location);
  
         //Initialize the Point with x, and y positions
         p = new Point();
         p.x = location[0];
         p.y = location[1];
      }
  
      // The method that displays the popup.
      private void showPopup(final Activity context, Point p)
      {
         int popupWidth = 550;
         int popupHeight = 350;
  
         // Inflate the popup_layout.xml
         LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup);
         LayoutInflater layoutInflater = (LayoutInflater) context
           .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         View layout = layoutInflater.inflate(R.layout.datepicker_popup, viewGroup);
  
         // Creating the PopupWindow
         final PopupWindow popup = new PopupWindow(context);
         popup.setContentView(layout);
         popup.setWidth(popupWidth);
         popup.setHeight(popupHeight);
         popup.setFocusable(true);
  
         // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
         int OFFSET_X = 7;
         int OFFSET_Y = 65;
  
         // Clear the default translucent background
         popup.setBackgroundDrawable(new BitmapDrawable());
  
         // Displaying the popup at the specified location, + offsets.
         popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y);
  
  
  
         // Getting a reference to Close button, and close the popup when clicked.
         Button close = (Button) layout.findViewById(R.id.close);
         close.setOnClickListener(new OnClickListener()
         {
             /* disable(content_view);*/
           @Override
           public void onClick(View v) 
           {
              popup.dismiss();
           }
         });
  </code></pre>
  
  <p>Here is my custom layout for popup window</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
          &lt;LinearLayout
              android:id="@+id/popup"
              android:layout_width="308dp"
              android:layout_height="224dp"
              android:layout_marginLeft="3dp"
              android:layout_marginRight="3dp"
              android:background="@drawable/popup_bg"
              android:orientation="vertical" &gt;
  
          &lt;Button
              android:id="@+id/close"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="10dp"
              android:text="Close" /&gt;
  
          &lt;Button
              android:id="@+id/now"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:text="Now" /&gt;
  
          &lt;Button
              android:id="@+id/done"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:text="Done" /&gt;
  
          &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>