我有课:
class AdmobAds
{
private static final int ADVIEW_NOT_INITIALIZED = 1;
private AdView adView;
public int InitAds(final String pub_id)
{
LoaderActivity.m_Activity.runOnUiThread(new Runnable() {
@Override
public void run() {
adView = new AdView(LoaderActivity.m_Activity, AdSize.BANNER, pub_id);
adView.loadAd(new AdRequest());
LoaderActivity.m_Activity.addContentView(adView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
});
return 0;
}
public int ShowAds()
{
if(adView!=null){
LoaderActivity.m_Activity.runOnUiThread(new Runnable() {
@Override
public void run() {
adView.setVisibility(View.VISIBLE);
}});
} else {
return ADVIEW_NOT_INITIALIZED;
}
return 0;
}
public int HideAds()
{
if(adView!=null){
LoaderActivity.m_Activity.runOnUiThread(new Runnable() {
@Override
public void run() {
adView.setVisibility(View.INVISIBLE);
}});
} else {
return ADVIEW_NOT_INITIALIZED;
}
return 0;
}
}
我需要将 AdMob 横幅放置在已确定的位置 ix 和 iy 中。当我尝试添加 Layout 时,我们在其中放置了一个横幅应用程序。
应用写在Marmalade SDK上,所以用不上XML,一点经验也不能让我自己处理问题。