Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created February 10, 2015 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimmduh/2453e4ce6962f7056fff to your computer and use it in GitHub Desktop.
Save dimmduh/2453e4ce6962f7056fff to your computer and use it in GitHub Desktop.
package utils;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import utils.Utils;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
public class AdmobBannerPreference extends Preference {
public AdmobBannerPreference(Context context) {
super(context, null);
}
public AdmobBannerPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected View onCreateView(ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View result = inflater.inflate(Utils.getResourceIdByName(getContext(), "layout/admob_banner_preference", getContext().getPackageName()), null);
AdView adView = new AdView(getContext());
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-647578" + "5814" + "0810/3205" + "241681");
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(adRequest);
((LinearLayout)result.findViewById(wallpaper.live.skulls.R.id.adView)).addView(adView);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment