вторник, 13 сентября 2011 г.

Add AdMob AdView to PreferenceActivity

Simple solution to add AdMob advert to Live Wallpaper settings screen is create new type which will show AdMob AdView and then include it into PreferenceScreen.

1) Add new type 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) {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        return inflater.inflate(R.layout.admob_preference, null);
    }
}
2) Add admob_preference.xml to res/layout:

 
           

3) Now you can use your type within PreferenceScreen.


 
 ...

Комментариев нет:

Отправить комментарий