2
我设法将adMob添加到标题屏幕,该屏幕使用* .xml文件编写。如何在Android中将AdMob添加到ViewClass中
setContentView(R.layout.main);
AdView adView = (AdView)findViewById(R.id.ad);
adView.requestFreshAd();
main.xml中包含:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/de.xazen.tictactoe"
android:background="@drawable/title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</RelativeLayout>
游戏本身是写在Tttview。
public class TttView extends View
活动Game.java创建一个TttView的实例并使用setcontent(tttView)将其用作布局。
public class Game extends Activity{
private TttView tttView;
.
.
.
setContentView(tttView);
}
如何将adMob添加到游戏本身?