how to hide ad when the internet is not available
<p>I am making an application in which i am giving an add.But even when the internet connection not available,it takes space in the view/layout.I just want to hide it and to not allow it taking space in layout/view when the internet is not available.This is the xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:orientation="vertical" &gt;

    &lt;FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" &gt;

        &lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="visible" &gt;

            &lt;ImageView
                android:id="@+id/explain_QuestionImageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="visible" /&gt;

            &lt;ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5.0dip"
                android:layout_marginLeft="1.0dip"
                android:layout_marginRight="1.0dip"
                android:layout_marginTop="1.0dip"
                android:fadeScrollbars="true"
                android:fadingEdge="none"
                android:fillViewport="true" &gt;

                &lt;TextView
                    android:id="@+id/explain_question"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@id/explain_QuestionImageView"
                    android:fadingEdge="vertical"
                    android:scrollbars="vertical"
                    android:text=""
                    android:textColor="@color/question_text"
                    android:textColorHighlight="@color/question_text1" /&gt;
            &lt;/ScrollView&gt;

            &lt;TextView
                android:id="@+id/explain_separator"
                android:layout_width="match_parent"
                android:layout_height="5.0dip"
                android:layout_alignParentRight="true"
                android:layout_below="@id/explain_question"
                android:background="@drawable/blue_gradient"
                android:fadingEdge="vertical"
                android:padding="10dp"
                android:scrollbars="vertical"
                android:text="" /&gt;

            &lt;ScrollView
                android:id="@+id/scrollView2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="100.0dip"
                android:layout_marginLeft="1.0dip"
                android:layout_marginRight="1.0dip"
                android:layout_marginTop="1.0dip"
                android:fadeScrollbars="true"
                android:fadingEdge="none"
                android:fillViewport="true" &gt;

                &lt;TextView
                    android:id="@+id/explain_explaination"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@id/explain_separator"
                    android:fadingEdge="vertical"
                    android:padding="10dp"
                    android:scrollbars="vertical"
                    android:text=""
                    android:textColor="@color/dark_green" /&gt;
            &lt;/ScrollView&gt;
        &lt;/LinearLayout&gt;
        &lt;!-- &lt;/ScrollView&gt; --&gt;

    &lt;/FrameLayout&gt;

    &lt;RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
       &gt;

        &lt;com.google.ads.AdView
            android:id="@+id/ad"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:keepScreenOn="true"
            ads:adSize="BANNER"
            ads:adUnitId="a1501e5633125fb"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR, 123456789ABCDEF" &gt;
        &lt;/com.google.ads.AdView&gt;

        &lt;LinearLayout
            android:id="@+id/LL_Buttons1"
            android:layout_width="fill_parent"
            android:layout_height="40.0dip"
            android:layout_above="@id/ad"
            android:layout_gravity="bottom"
            android:background="#ff777777"
            android:orientation="horizontal" &gt;

            &lt;Button
                android:id="@+id/PrevExplainationButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="2.0dip"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onPrevExplainationButtonClick"
                android:text="Previous" /&gt;

            &lt;Button
                android:id="@+id/NextExplainationButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_marginRight="2.0dp"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onNextExplainationButtonClick"
                android:text="Next" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/RelativeLayout&gt;
</code></pre>

<p></p>

<p>please tell me how to do it.</p>
