1

我必须在布局中制作两个 AdView。布局的顶部和底部。我已经完成了一个(顶部)。现在我想在布局底部再添加一个 AdView。如何实现?提前致谢。我的布局中顶部 AdView 的代码如下。

@SuppressWarnings({ "deprecation", "unused" })
public class BannerEssentials extends Activity{
WebView webview;
static String MY_BANNER_UNIT_ID="google";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// BANNER 1

// Lookup R.layout.main
AbsoluteLayout layout = (AbsoluteLayout)findViewById(R.id.linearLayout);

// Create the adView
// Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
AdView adView = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);

// Add the adView to it
layout.addView(adView);

// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();
request.setTesting(true);

adView.loadAd(request)
4

1 回答 1

0

使用 width="fill_parent" 和 height="0dip" 将另一个项目添加到线性布局。然后设置权重=“1”。这应该具有将下面的任何东西向下推的效果。然后复制上面的代码以添加新的广告。

您应该考虑在 XML 中定义您的视图,广告也可以直接通过 XML 插入,或者您也可以定义自己的自定义视图

于 2011-08-23T12:10:55.867 回答