在市场上,我看到一个应用程序在警告对话框中显示 admob。在我阅读之后this和 this和 this ,
我仍然不知道如何在如下所示的警告对话框中显示广告。 (或任何其他方法,可以在提醒对话框中显示广告)
我一直在绞尽脑汁想弄清楚如何 这样做。
任何人都可以指导我完成如何 去做这件事?
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/