com.google.ads
Class AdView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.RelativeLayout
              extended by com.google.ads.AdView
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, Ad

public class AdView
extends RelativeLayout
implements Ad

The View that displays the ads. Sample code:

   public class MyActivity extends Activity {
     private AdView adView;

     public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       // Create an ad.
       adView = new AdView(this, AdSize.IAB_BANNER, "adUnitId");

       // Create an ad request.
       AdRequest adRequest = new AdRequest();
       // Fill out ad request.

       // Add the AdView to the view hierarchy. The view will have no size
       // until the ad is loaded.

       // Start loading the ad in the background.
       adView.loadAd(adRequest);
     }

     public void onDestroy() {
       // Destroy the AdView.
       adView.destroy();

       super.onDestroy();
     }
   }
 


Nested Class Summary
 
Nested classes/interfaces inherited from class android.widget.RelativeLayout
RelativeLayout.LayoutParams
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.DragShadowBuilder, View.MeasureSpec, View.OnAttachStateChangeListener, View.OnClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.widget.RelativeLayout
ABOVE, ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_LEFT, ALIGN_PARENT_BOTTOM, ALIGN_PARENT_LEFT, ALIGN_PARENT_RIGHT, ALIGN_PARENT_TOP, ALIGN_RIGHT, ALIGN_TOP, BELOW, CENTER_HORIZONTAL, CENTER_IN_PARENT, CENTER_VERTICAL, LEFT_OF, RIGHT_OF, TRUE
 
Fields inherited from class android.view.ViewGroup
FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, VISIBLE
 
Constructor Summary
AdView(Activity activity, AdSize adSize, String adUnitId)
          Creates an AdView.
AdView(Context context, AttributeSet attrs)
          Creates an AdView from an XML layout.
AdView(Context context, AttributeSet attrs, int defStyle)
          Creates an AdView from an XML layout.
 
Method Summary
 void destroy()
          Destroys the AdView.
 boolean isReady()
          See Ad.isReady().
 boolean isRefreshing()
          Returns true if the ad is currently automatically refreshing.
 void loadAd(AdRequest adRequest)
          See Ad.loadAd(AdRequest).
 void setAdListener(AdListener adListener)
          See Ad.setAdListener(AdListener).
 void stopLoading()
          See Ad.stopLoading().
 
Methods inherited from class android.widget.RelativeLayout
dispatchPopulateAccessibilityEvent, generateLayoutParams, getBaseline, requestLayout, setGravity, setHorizontalGravity, setIgnoreGravity, setVerticalGravity
 
Methods inherited from class android.view.ViewGroup
addFocusables, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, bringChildToFront, childDrawableStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchSetActivated, dispatchSetSelected, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, endViewTransition, findFocus, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildMeasureSpec, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutTransition, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isMotionEventSplittingEnabled, jumpDrawablesToCurrentState, layout, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onInterceptTouchEvent, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayout
 
Methods inherited from class android.view.View
addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, cancelLongPress, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeScroll, createContextMenu, destroyDrawingCache, draw, findViewById, findViewWithTag, focusSearch, forceLayout, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBottom, getContentDescription, getContext, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFilterTouchesWhenObscured, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getId, getKeepScreenOn, getKeyDispatcherState, getLayerType, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOverScrollMode, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getPivotX, getPivotY, getResources, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSystemUiVisibility, getTag, getTag, getTop, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, measure, offsetLeftAndRight, offsetTopAndBottom, onCheckIsTextEditor, onCreateInputConnection, onDragEvent, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onWindowFocusChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setActivated, setAlpha, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayerType, setLayoutParams, setLeft, setLongClickable, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollbarFadingEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, startActionMode, startAnimation, startDrag, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested
 

Constructor Detail

AdView

public AdView(Activity activity,
              AdSize adSize,
              String adUnitId)
Creates an AdView.

Parameters:
activity - the associated Activity.
adSize - the size of the ad.
adUnitId - the ad unit ID.

AdView

public AdView(Context context,
              AttributeSet attrs)
Creates an AdView from an XML layout.

Parameters:
context - the Context provided when inflating from an XML layout.
attrs - the AttributeSet provided when inflating from an XML layout.

AdView

public AdView(Context context,
              AttributeSet attrs,
              int defStyle)
Creates an AdView from an XML layout.

Parameters:
context - the Context provided when inflating from an XML layout.
attrs - the AttributeSet provided when inflating from an XML layout.
defStyle - the default style provided when inflating from an XML layout.
Method Detail

destroy

public void destroy()
Destroys the AdView. The AdView should no longer be used after this method is called.


isReady

public boolean isReady()
See Ad.isReady().

Specified by:
isReady in interface Ad
Returns:
true if the ad is successfully loaded and is ready to be shown.
See Also:
Ad.isReady()

isRefreshing

public boolean isRefreshing()
Returns true if the ad is currently automatically refreshing.

Returns:
true if the ad is currently automatically refreshing.

loadAd

public void loadAd(AdRequest adRequest)
See Ad.loadAd(AdRequest).

Specified by:
loadAd in interface Ad
Parameters:
adRequest - the AdRequest used to fetch the ad.
See Also:
Ad.loadAd(AdRequest)

setAdListener

public void setAdListener(AdListener adListener)
See Ad.setAdListener(AdListener).

Specified by:
setAdListener in interface Ad
Parameters:
adListener - the AdListener.
See Also:
Ad.setAdListener(AdListener)

stopLoading

public void stopLoading()
See Ad.stopLoading().

Specified by:
stopLoading in interface Ad
See Also:
Ad.stopLoading()