I try to add Admob in live wallpaper setting, but it shows "required xml attribute adsize was missing". I tried many methods that i seached in internet, but this methods don't solve a problem((( How to solve this problem< who know?
AdMobPreference.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:ads="http://ift.tt/1bhZ3VK"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-6437604595659430/1119994508"
ads:adSize="BANNER"/>
</LinearLayout>
AdmobPreference.java
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);
}
}
prefs.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://ift.tt/nIICcg"
android:orderingFromXml="true">>
<EditTextPreference android:key="number"
android:title="Speed of PushUps"></EditTextPreference>
**<ter.trimf.body_b_pushups.AdmobPreference android:key="adView"/>**
</PreferenceScreen>
No comments:
Post a Comment