Android中的自定义视图上的AdView

时间:2013-05-20 19:57:07

标签: android admob adview

我正在为我正在制作的游戏创建一个简单的视图。我有一个标题屏幕,我想使用AdView显示广告。

在我的构造函数中我有这个:

public TitleView(Context context) 
{
    super(context);

    myContext = context;
    titleGraphic = BitmapFactory.decodeResource(getResources(), R.drawable.title_graphic);
    playButtonUp = BitmapFactory.decodeResource(getResources(), R.drawable.play_button_up);
    playButtonDown = BitmapFactory.decodeResource(getResources(), R.drawable.play_button_down);

    layout = new LinearLayout(myContext);
    layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    adView = new AdView((Activity)myContext, AdSize.SMART_BANNER, "a151967e40a4400");
    adView.setVisibility(View.VISIBLE);

    layout.addView(adView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    adView.loadAd(new AdRequest());

    this.setBackgroundColor(Color.BLACK);
}

在我的onDraw方法中,我有以下内容:

    layout.measure(screenW, screenH);
    layout.layout(0, 0, screenW, screenH);
    layout.draw(canvas);

问题是,图片正在加载,我在LogCat中看到了adView请求,但我从未看到应用中显示的AD。我做错了什么?

0 个答案:

没有答案