1

I'm trying to implement Admob banner in Custom Dialog box.

I want to make in in XML 'cause i'm thinking this is simplier to change it positions etc.

So here is fragment from my GameActivity where is Custom Dialog too.

Fragment with dialog:

 public void showRestartDialog() {


    final Dialog dialog = new Dialog(GameActivity.this);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    dialog.setContentView(R.layout.activity_dialog);

    //set up image view
    ImageView img = (ImageView) dialog.findViewById(R.id.imageView1);
    img.setImageResource(R.drawable.puste);

int highest = PrefUtil.getHighestScore(this);
String text = null;
if (currentPoint > highest) {
  highest = currentPoint;
  PrefUtil.setHighestScore(this, currentPoint);
} else {
}
text = "\n  " + currentPoint + "\n\n  " + highest;



   TextView text1 = (TextView)





           dialog.findViewById(R.id.TextView01);
   text1.setText(text);
   AdView adView = (AdView)dialog.findViewById(R.id.adView);
   AdRequest adRequest = new AdRequest.Builder().build();
   adView.loadAd(adRequest);

Where is a problem? With this code, the dialog is showing but without banner. Help me please!

Greetings!

4

1 回答 1

0

我不认为你想这样做。广告可能需要很长时间才能加载,并且在对话框仍然显示时您可能不会收到广告。当您说它不显示任何广告时,这可能是您希望看到的。

您最好在整个应用程序的主页上连续显示横幅,或者在游戏结束时显示插页式广告。

于 2014-03-05T03:43:55.133 回答