Java Code Examples for android.widget.RelativeLayout#removeView()

The following examples show how to use android.widget.RelativeLayout#removeView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HWWebView.java    From RePlugin-GameSdk with Apache License 2.0 6 votes vote down vote up
/**
	 * 显示自定义错误提示页面
	 */
	protected void showErrorPage() {
		webParentView = (RelativeLayout) getParent();

		initErrorPage();
		
		while (webParentView.getChildCount() > 0) {
			webParentView.removeView(mMebView);
		}
		
		refreshLinearLayout.setVisibility(View.VISIBLE);
		
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
//		lp.addRule(RelativeLayout.CENTER_IN_PARENT);
		webParentView.addView(refreshLinearLayout, 0, lp);
		
		mIsErrorPage = true;
	}
 
Example 2
Source File: GDMopub.java    From GodotAds with Apache License 2.0 6 votes vote down vote up
private void createBanner() {
       RelativeLayout layout = new RelativeLayout(activity);
       layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
       ((Godot)activity).layout.addView(layout);

	FrameLayout.LayoutParams AdParams = new FrameLayout.LayoutParams(
					 FrameLayout.LayoutParams.MATCH_PARENT,
					 FrameLayout.LayoutParams.WRAP_CONTENT);

	if(moPubView != null) { layout.removeView(moPubView); }

	if (_config.optString("BannerGravity", "BOTTOM").equals("BOTTOM")) {
		AdParams.gravity = Gravity.BOTTOM;
	} else { AdParams.gravity = Gravity.TOP; }

	final String banner_unit_id =
	_config.optString("BannerAdId", activity.getString(R.string.gads_mopub_banner_test_id));

	moPubView = new MoPubView(activity);
	moPubView.setLayoutParams(AdParams);
	moPubView.setAdUnitId(banner_unit_id); // Enter your Ad Unit ID from www.mopub.com
	moPubView.setBannerAdListener(banner_listener);
	moPubView.setAutorefreshEnabled(true);
	moPubView.setVisibility(View.INVISIBLE);
	moPubView.loadAd();

	layout.addView(moPubView);
}
 
Example 3
Source File: MainActivity.java    From scroball with MIT License 6 votes vote down vote up
@Override
public void onPurchasesUpdated(int responseCode, List<Purchase> purchases) {
  if (responseCode != BillingResponse.OK) {
    purchaseFailed();
  } else if (purchases != null) {
    for (Purchase purchase : purchases) {
      if (purchase.getSku().equals(REMOVE_ADS_SKU)) {
        RelativeLayout parent = (RelativeLayout) adView.getParent();
        if (parent != null) {
          parent.removeView(adView);
        }
        this.invalidateOptionsMenu();
        this.adsRemoved = true;
        SharedPreferences.Editor editor = application.getSharedPreferences().edit();
        editor.putBoolean(REMOVE_ADS_SKU, true);
        editor.apply();
      }
    }
  }
}
 
Example 4
Source File: MainActivity.java    From scroball with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  application = (ScroballApplication) getApplication();
  application.startListenerService();

  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  // Create the adapter that will return a fragment for each of the three
  // primary sections of the activity.
  mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

  // Set up the ViewPager with the sections adapter.
  mViewPager = findViewById(R.id.container);
  mViewPager.setAdapter(mSectionsPagerAdapter);

  TabLayout tabLayout = findViewById(R.id.tabs);
  tabLayout.setupWithViewPager(mViewPager);

  // Initial tab may have been specified in the intent.
  int initialTab = getIntent().getIntExtra(EXTRA_INITIAL_TAB, TAB_NOW_PLAYING);
  mViewPager.setCurrentItem(initialTab);

  this.adsRemoved = application.getSharedPreferences().getBoolean(REMOVE_ADS_SKU, false);

  adView = findViewById(R.id.adView);
  if (this.adsRemoved) {
    RelativeLayout parent = (RelativeLayout) adView.getParent();
    if (parent != null) {
      parent.removeView(adView);
    }
  } else {
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice("86193DC9EBC8E1C3873178900C9FCCFC").build();
    adView.loadAd(adRequest);
  }
}
 
Example 5
Source File: AdsManager.java    From FruitCatcher with Apache License 2.0 5 votes vote down vote up
public void removeAdView(RelativeLayout layout) {
    if (adView != null) {
        layout.removeView(adView);
        adHeight = 0;
        adView = null;
    }
}
 
Example 6
Source File: GodotAdMob.java    From godot_modules with MIT License 5 votes vote down vote up
void SetBannerView()
{
	RelativeLayout layout = ((Godot)activity).layout;
	RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
               LayoutParams.WRAP_CONTENT);
	
	layoutParams.addRule(layoutRule1);
	layoutParams.addRule(layoutRule2);
	
	layout.removeView(adView);
	layout.addView(adView, layoutParams);		
}