Display Progress Dialog While AdMob Fetches Ad
My app has an activity where the ad is best placed in the center of the screen. I've made the other elements sit relative to the ad either above or below. I like the way it looks when the ad is present, but when the activity starts everything is mashed together.
What I would like to do is display a progress dialog in the space where the ad will go if AdMob delivers an ad.
I have implemented my ads in the XML way documented here: http://code.google.com/mobile/ads/docs/android/banner_xml.html
Can someone put me on the right path?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.aydabtu.BroadcastSMS"
android:orientation="ver开发者_StackOverflow社区tical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/megaphone_320x480"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="left"
android:text="@string/num_messages"
android:background="@drawable/semiTransparentLt"
android:textColor="@drawable/black"
android:textStyle="bold"
android:id="@+id/num_msgs_title"
android:layout_above="@+id/smsMsgBody_editText"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="0"
android:background="@drawable/semiTransparentLt"
android:textColor="@drawable/black"
android:textStyle="bold"
android:id="@+id/num_msgs"
android:layout_toRightOf="@id/num_msgs_title"
android:layout_alignTop="@id/num_msgs_title"
/>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:singleLine="false"
android:lines="5"
android:minLines="5"
android:gravity="top|left"
android:id="@id/smsMsgBody_editText"
android:hint="@string/sms_edittext"
android:layout_above="@+id/body_len"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="right"
android:paddingRight="10sp"
android:text="0"
android:background="@drawable/semiTransparentLt"
android:textColor="@drawable/black"
android:textStyle="bold"
android:id="@id/body_len"
android:layout_above="@+id/ad"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="left"
android:paddingRight="10sp"
android:text="@string/clear_text"
android:background="@drawable/semiTransparentLt"
android:textColor="@drawable/black"
android:textStyle="bold"
android:id="@+id/clear_text"
android:layout_above="@id/ad"
/>
<com.admob.android.ads.AdView
android:id="@id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="@drawable/black"
myapp:primaryTextColor="@drawable/white"
myapp:secondaryTextColor="@drawable/drkGrey"
android:layout_above="@+id/broadcastMsg_button"
/>
<Button
android:layout_height="wrap_content"
android:id="@id/broadcastMsg_button"
android:layout_width="fill_parent"
android:text="@string/broadcast_sms_button"
android:layout_centerInParent="true"
/>
</RelativeLayout>
I'd say place a frame layout where you have the AdView now. Place an AdView and circular ProgressBar within the AdView. Might need some tweaking to hide the ProgressBar once the AdView appears, but should be work.
If you post your exact XML. I will give a more detailed explanation.
精彩评论