我正在尝试在动态壁纸的设置页面中设置广告横幅,但尽管我尝试了多次尝试但无法添加广告。我遵循了许多教程,但都不起作用。请告诉我我做错了什么。
我遵循了本教程
http://irinaramazova.blogspot.in/2011/09/add-admob-adview-to-preferenceactivity.html
我也看到了这个有用的
How do I put an admob adview in the settings screen for a live wallpaper?
既不起作用。 我的代码如下
我的Admobpreference类
public class AdmobPreference extends Preference
{
public AdmobPreference(Context context) {
super(context, null);
}
public AdmobPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected View onCreateView(ViewGroup parent) {
//override here to return the admob ad instead of a regular preference display
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(R.layout.admob_preference, null);
}
}
admobpreference.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.djcharon.valentinesday"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent" android:layout_height="fill_parent"
>
<com.google.ads.adview android:id="@+id/adView" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adunitid="myid" ads:adsize="BANNER" >
</com.google.ads.adview>
</LinearLayout>
我的activity_preference.xml文件
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<com.djcharon.valentinesday.AdmobPreference android:key="adView" />
<CheckBoxPreference android:key="touch" android:title="Enable Touch" android:defaultValue="true"></CheckBoxPreference>
<ListPreference android:key="kiss" android:title="Wallpaper" android:summary="Select the Wallpaper" android:defaultValue="Background 1" android:entries="@array/listKissSound" android:entryValues="@array/listKissSound" ></ListPreference>
<ListPreference android:key="heartLife" android:title="Particle life" android:summary="The Particle lifecicle." android:defaultValue="20" android:entries="@array/listLifeCicle" android:entryValues="@array/listLifeCicle" ></ListPreference>
</PreferenceScreen>
我在清单中添加了活动
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
</activity>
我收到错误
错误地夸大了com.google.ads.adView
答案 0 :(得分:0)
现在,Admob使用了google-playstore service
库。
请参阅以下链接。
https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals