java - 自定义警报对话框中的 Admob(Ads)

标签 java android dialog

在市场上,我看到一个应用程序在警告对话框中显示 admob。在我阅读之后thisthisthis ,

我仍然不知道如何在如下所示的警告对话框中显示广告。 (或任何其他方法,可以在提醒对话框中显示广告)

enter image description here

我一直在绞尽脑汁想弄清楚如何 这样做。

任何人都可以指导我完成如何 去做这件事?

XML:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@id/tablayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="*"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:myapp="http://schemas.android.com/apk/res/com.xxx.xxx">

    <TableRow>
  <com.admob.android.ads.AdView android:id="@id/myad" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  myapp:backgroundColor="#ff000000" 
  myapp:primaryTextColor="#ffffffff" 
  myapp:secondaryTextColor="#ffcccccc" />
    </TableRow>

</TableLayout>

Java:

 public void onBackPressed() {
    //set up dialog
                Dialog dialog = new Dialog(main.this);
                dialog.setContentView(R.layout.exitdialog);
                dialog.setTitle("This is my custom dialog box");
                dialog.setCancelable(true);


                //set up button
                Button button = (Button) dialog.findViewById(R.id.Button01);
                button.setOnClickListener(new OnClickListener() {
                @Override
                    public void onClick(View v) {
                        finish();
                    }
                });
                //now that the dialog is set up, it's time to show it    
                dialog.show();
            }
        });
}

谢谢。

最佳答案

我找到了另一种解决方案。

AdMob 为 Android 和 iPhone 网站/网络应用程序提供了 JavaScript 集成解决方案。

而不是使用 XML 和自定义对话框。 我们可以使用 Admob 网络广告和包含 admob 代码的 HTML,并在对话框中使用 webview 加载它。

关于java - 自定义警报对话框中的 Admob(Ads),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7633499/

相关文章:

java - 如何关闭 fakemongo 日志

java - 替换 spring 配置文件特定属性文件中的属性占位符

Java 泛型 : Cannot cast List<Class<R>> to List<Class>

android - 编写 .json 文件并在 Android 中读取该文件

android - StrictModeDiskReadViolation 只能通过 AsyncTask 解决,为什么?

在 JSTL 中使用 Java ArrayList(<c :foreach>)

android - 如何将操作栏添加到滑动 View ?

javascript - 如何将值从 gridview 传递给 javascript 函数

java - 调用 dispose 时,自定义对话框不会释放

android - 对话框显示两次