網路上找得到的範例, 全部可以說差不多都在講如何以 XML 定義那臭長的 AdView, 現在我自己試出來, 完全不靠 XML 使用簡單的 FrameLayout 玩疊疊樂就能實現, 至於參數說明可以參考 AdView 的說明頁, 再參考 如何在 Android 應用安裝 AdMob (跳過第 4 步)
在 Activity 底下 設一個私有變數 static private AdView mAd, SampleView 是自己建立要來畫東西做什麼事的, 再參照下例 :
FrameLayout FL= new FrameLayout(this);
mSampleView=new SampleView(this);
FL.addView(mSampleView);
mAd = new AdView(this);
if (mAd!=null){
mAd.setRequestInterval(60);
mAd.setVisibility( View.VISIBLE );
// Make the ad disappear with the text or a new ad appear.
mAd.requestFreshAd();
}
FL.addView(mAd);
setContentView(FL);
這樣子大概入口就完成了, 剩下的靠各位達人的毅力啦 !
沒有留言:
張貼留言