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

The following are Jave code examples for showing how to use removeView() of the android.widget.RelativeLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GodotAds   File: GDMopub.java   Source Code and License Vote up 6 votes
private void createBanner() {
	RelativeLayout layout = ((Godot)activity).adLayout; // Getting Godots framelayout
	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.ad_unit_id_banner));

	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 2
Project: FloatingNew   File: FloatingViewServiceOpen.java   Source Code and License Vote up 5 votes
private void populateRecycleView() {
//
        if (!result.isEmpty()) {

            RecyclerView nApp = (RecyclerView) mFloatingView.findViewById(R.id.recyclerView);
            if (result.size() > 4) {
                RelativeLayout main = (RelativeLayout) mFloatingView.findViewById(R.id.up_view);
                RelativeLayout.LayoutParams shape = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, (int) getResources().getDimension(R.dimen.recycle));
                shape.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
              /*  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    shape.addRule(RelativeLayout.ALIGN_PARENT_START, RelativeLayout.TRUE);
                }*/
                shape.addRule(RelativeLayout.ALIGN_TOP, R.id.up_iv);
                shape.setMargins(220, 220, 0, 0);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    nApp.setBackgroundColor(this.getColor(R.color.param));
                } else {
                    //noinspection deprecation
                    nApp.setBackgroundColor(getResources().getColor(R.color.param));
                }
                main.removeView(nApp);
                main.addView(nApp, shape);
            }
            nApp.setLayoutManager(new LinearLayoutManager(FloatingViewServiceOpen.this));
            // nApp.setLayoutManager(new GridLayoutManager(getApplicationContext(),3));
            nApp.setHasFixedSize(true);
            nApp.setAdapter(new RecyclerViewAdapterResult(FloatingViewServiceOpen.this, result));

        } else {
            Toast.makeText(this, "No App Selected Please Select An App", Toast.LENGTH_SHORT).show();
        }

    }