我通过画布添加 AdMob:
public void drawAddMob(final Activity a){
a.runOnUiThread(new Runnable(){
public void run(){
LinearLayout ll = new LinearLayout(a);
ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
adView = new AdView(a, AdSize.BANNER, "a15140cd49b6e7b");
adView.setLayoutParams(new LayoutParams(320,50));
AdRequest request = new AdRequest();
adView.loadAd(request);
ll.addView(adView);
ll.draw(canvas);
}});
}
但是当它加载时我得到这样的错误:
W/webcore(347): Can't get the viewWidth after the first layout
及其重新加载-再次请求admob,每次我收到此错误,3次后它停止并写入“onRecieveAd()”但它没有出现在屏幕上并且仍然在它之前我得到错误