我开始使用libGDX,我想在我的游戏中使用AdMob。
如果有人已经参与其中,请给我一些方法让这件事在游戏中发生?
答案 0 :(得分:5)
layout = new RelativeLayout(this);
adView = new AdView(this, AdSize.BANNER, adMObid );
View gameView=initializeForView(new TalkingFriendApp(this), cfg);
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
RelativeLayout.LayoutParams adParams1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
adView.loadAd(new AdRequest());
layout.addView(gameView, adParams);
layout.addView(adView, adParams1);
setContentView(layout);
答案 1 :(得分:1)
用于集成到您的应用See Here
adView = new AdView(this, AdSize.BANNER, "YourID");
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
layout.addView(adView);
AdRequest request = new AdRequest();
request.setTesting(false);
adView.loadAd(request);