0
AdMob廣告在我的應用程序沒有顯示。我感覺廣告正在加載,但由於我的佈局安排,不知何故它沒有顯示。但我找不到它。這裏是我的代碼AdMob廣告在我的應用程序沒有顯示
protected void onSetContentView() {
final RelativeLayout relativeLayout = new RelativeLayout(this);
final FrameLayout.LayoutParams relativeLayoutLayoutParams = new FrameLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
this.mRenderSurfaceView = new RenderSurfaceView(this);
mRenderSurfaceView.setRenderer(mEngine);
final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT,Gravity.CENTER);
final android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams = new RelativeLayout.LayoutParams(layoutParams);
surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
FrameLayout frameLayout = new FrameLayout(this);
adView = new AdView(this, AdSize.BANNER, "##############");
adView.refreshDrawableState();
adView.setVisibility(AdView.VISIBLE);
frameLayout.addView(adView);
relativeLayout.addView(frameLayout);
this.setContentView(relativeLayout, relativeLayoutLayoutParams);
}
你有沒有考慮建立從XML佈局,而不是從代碼?試試這個 –
即時通訊使用andengine這就是爲什麼我不能使用XML來做到這一點。有沒有什麼辦法可以在andengine – jquery404
你可以用andengine在XML中做到這一點。看看andengine的例子。有一個演示如何做到這一點。 https://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/XMLLayoutExample.java?r=15154df3b77a317ce4e8fd643d4059f536a458c5 –