这是我在MainActivity.java中的代码。
有人可以帮助我解决这个问题:我使用eclipse并在平板电脑上测试我的应用程序。它运作良好,但不会看到admob广告。
为什么呢?
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams gameViewParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
//gameViewParams.bottomMargin = 150;
requestWindowFeature( Window.FEATURE_NO_TITLE );
View gameView = initializeForView(listener, cfg);
layout.addView(gameView, gameViewParams);
AdView adView = new AdView(this);
adView.setAdUnitId("Ad ID");
//adView.setAdUnitId("app-id");
adView.setAdSize(AdSize.BANNER);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(adView, adParams);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
setContentView(layout);
答案 0 :(得分:0)
与我的代码相比,我看到的唯一不同的是youradParams。
试试这个:
final RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);