Created
February 10, 2015 05:52
-
-
Save dimmduh/2453e4ce6962f7056fff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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