Code example for LinearLayout.LayoutParams

0
 
	protected void showAd() { 
		this.removeAd();
		View ad = AdsManager.getAd(this);
		if (ad != null) {
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
			lp.gravity = Gravity.CENTER_HORIZONTAL;
			adsContainer.addView(ad, lp);
		}		 
	} 
	 
	protected void removeAd() { 
		adsContainer.removeAllViews();
	} 
	 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);				
		setContentView(R.layout.settings);
		adsContainer = (ViewGroup) findViewById(R.id.adsContainer);
		this.showAd();