Example usage for android.widget FrameLayout addView

List of usage examples for android.widget FrameLayout addView

Introduction

In this page you can find the example usage for android.widget FrameLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.koushikdutta.desksms.plugin.EditActivity.java

/**
 * {@inheritDoc}//from   w  w  w.  j a  va  2s  . c  o  m
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*
     * A hack to prevent a private serializable classloader attack
     */
    BundleManager.scrub(getIntent());
    BundleManager.scrub(getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE));

    setContentView(R.layout.main);

    setTitle(BreadCrumber.generateBreadcrumb(getApplicationContext(), getIntent(),
            getString(R.string.plugin_name)));

    final FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
    frame.addView(getLayoutInflater().cloneInContext(new ContextThemeWrapper(this, R.style.Theme_Locale_Light))
            .inflate(R.layout.frame, frame, false));

    bindUIElements();
    /*
     * if savedInstanceState == null, then then this is a new Activity instance and a check for EXTRA_BUNDLE is needed
     */
    if (savedInstanceState == null) {
        final Bundle forwardedBundle = getIntent()
                .getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);

        if (BundleManager.isBundleValid(forwardedBundle)) {
            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_EMAIL)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_EMAIL);
                mChkEmail.setChecked(true);
                mToggleEmail.setChecked(enabled);
            } else {
                mChkEmail.setChecked(false);
                mToggleEmail.setEnabled(false);
            }

            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_WEB)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_WEB);
                mChkWeb.setChecked(true);
                mToggleWeb.setChecked(enabled);
            } else {
                mChkWeb.setChecked(false);
                mToggleWeb.setEnabled(false);
            }

            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_XMPP)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_XMPP);
                mChkXMPP.setChecked(true);
                mToggleXMPP.setChecked(enabled);
            } else {
                mChkXMPP.setChecked(false);
                mToggleXMPP.setEnabled(false);
            }
        } else {
            setDefaults();
        }
    }
}

From source file:com.koushikdutta.desktopsms.plugin.EditActivity.java

/**
 * {@inheritDoc}//w  w w. j  a v  a  2s . c o  m
 */
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*
     * A hack to prevent a private serializable classloader attack
     */
    BundleManager.scrub(getIntent());
    BundleManager.scrub(getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE));

    setContentView(R.layout.plugin);

    setTitle(BreadCrumber.generateBreadcrumb(getApplicationContext(), getIntent(),
            getString(R.string.plugin_name)));

    final FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
    frame.addView(getLayoutInflater().cloneInContext(new ContextThemeWrapper(this, R.style.Theme_Locale_Light))
            .inflate(R.layout.frame, frame, false));

    bindUIElements();
    /*
     * if savedInstanceState == null, then then this is a new Activity instance and a check for EXTRA_BUNDLE is needed
     */
    if (savedInstanceState == null) {
        final Bundle forwardedBundle = getIntent()
                .getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);

        if (BundleManager.isBundleValid(forwardedBundle)) {
            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_EMAIL)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_EMAIL);
                mChkEmail.setChecked(true);
                mToggleEmail.setChecked(enabled);
            } else {
                mChkEmail.setChecked(false);
                mToggleEmail.setEnabled(false);
            }

            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_WEB)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_WEB);
                mChkWeb.setChecked(true);
                mToggleWeb.setChecked(enabled);
            } else {
                mChkWeb.setChecked(false);
                mToggleWeb.setEnabled(false);
            }

            if (forwardedBundle.containsKey(BundleManager.BUNDLE_EXTRA_FORWARD_XMPP)) {
                boolean enabled = forwardedBundle.getBoolean(BundleManager.BUNDLE_EXTRA_FORWARD_XMPP);
                mChkXMPP.setChecked(true);
                mToggleXMPP.setChecked(enabled);
            } else {
                mChkXMPP.setChecked(false);
                mToggleXMPP.setEnabled(false);
            }
        } else {
            setDefaults();
        }
    }
}

From source file:org.wingy.jp8chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();//from  w  w  w  .ja va 2s  . co m
        return;
    }

    threadManager = threadManagerStatic;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}

From source file:at.jclehner.rxdroid.ui.DialogLike.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.layout_dialogue_like, container, false);

    mTitle = (TextView) v.findViewById(R.id.title);
    mMessage = (TextView) v.findViewById(R.id.message);
    mDetail = (TextView) v.findViewById(R.id.detail);
    mIcon = (ImageView) v.findViewById(R.id.icon);
    mButtonBar = v.findViewById(R.id.button_bar);

    final int posBtn, negBtn;

    if (!isRtlLanguage()) {
        posBtn = R.id.btn_right;/* w w  w.  j  a v a 2  s  . co m*/
        negBtn = R.id.btn_left;
    } else {
        posBtn = R.id.btn_left;
        negBtn = R.id.btn_right;
    }

    mPositiveBtn = (Button) v.findViewById(posBtn);
    mNegativeBtn = (Button) v.findViewById(negBtn);

    mPositiveBtn.setOnClickListener(mBtnListener);
    mNegativeBtn.setOnClickListener(mBtnListener);

    final int customView = getArguments().getInt("custom_view");
    final FrameLayout customViewFrame = (FrameLayout) v.findViewById(R.id.custom);

    if (mCustomView != null)
        customViewFrame.addView(mCustomView);
    else if (customView != 0)
        mCustomView = inflater.inflate(customView, customViewFrame, true);

    if (mCustomView != null) {
        customViewFrame.setVisibility(View.VISIBLE);
        onBindCustomView(mCustomView);
    }

    applyArguments();

    return v;
}

From source file:com.harlan.jxust.ui.view.bottombar.BottomBarBadge.java

protected BottomBarBadge(Context context, int position, final View tabToAddTo, // Rhyming accidentally! That's a Smoove Move!
        int backgroundColor) {
    super(context);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    setLayoutParams(params);//from  ww w .j ava2  s .  c  o m
    setGravity(Gravity.CENTER);
    MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text);

    int three = MiscUtils.dpToPixel(context, 3);
    ShapeDrawable backgroundCircle = BadgeCircle.make(three * 3, backgroundColor);
    setPadding(three, three, three, three);
    setBackgroundCompat(backgroundCircle);

    FrameLayout container = new FrameLayout(context);
    container.setLayoutParams(params);

    ViewGroup parent = (ViewGroup) tabToAddTo.getParent();
    parent.removeView(tabToAddTo);
    container.addView(tabToAddTo);
    container.addView(this);
    parent.addView(container, position);

    container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onGlobalLayout() {
            adjustPositionAndSize(tabToAddTo);
        }
    });
}

From source file:org.floens.chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapterStatic == null || threadManagerStatic == null) {
        Logger.e(TAG, "postadapter or threadmanager null");
        finish();/*from  w  w  w.j a  va 2  s  .com*/
        return;
    }

    threadManager = threadManagerStatic;
    threadManagerStatic = null;
    postAdapter = postAdapterStatic;
    postAdapterStatic = null;
    int selectedId = selectedIdStatic;
    selectedIdStatic = -1;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}

From source file:com.community.yuequ.bottombar.BottomBarBadge.java

private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) {
    ViewGroup tabContainer = (ViewGroup) tab.getParent();
    tabContainer.removeView(tab);//  w w  w.  j  a v  a2s.co m

    final FrameLayout badgeContainer = new FrameLayout(getContext());
    badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    badgeContainer.addView(tab);
    badgeContainer.addView(this);

    tabContainer.addView(badgeContainer, tab.getIndexInTabContainer());

    badgeContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @SuppressWarnings("deprecation")
                @Override
                public void onGlobalLayout() {
                    badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    adjustPositionAndSize(tab);
                }
            });
}

From source file:com.l4digital.fastscroll.FastScrollRecyclerView.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    mFastScroller.attachRecyclerView(this);

    final ViewParent parent = getParent();

    if (parent instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) parent;
        if ((viewGroup instanceof CoordinatorLayout) || (viewGroup instanceof FrameLayout)
                || (viewGroup instanceof RelativeLayout)) {
            if (mFastScroller.getParent() == null) {
                viewGroup.addView(mFastScroller);
                mFastScroller.setLayoutParams(viewGroup);
            }/*  ww  w.  ja  v a  2 s .c  om*/
        } else {
            if (viewGroup instanceof SwipeRefreshLayout) {
                mFastScroller.swipeRefreshLayout = (SwipeRefreshLayout) viewGroup;
            }
            final int index = viewGroup.indexOfChild(this);
            viewGroup.removeView(this);
            final FrameLayout fr = new FrameLayout(getContext());
            fr.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
            fr.addView(this);
            fr.addView(mFastScroller);
            mFastScroller.setLayoutParams(fr);
            viewGroup.addView(fr, index);
        }
    }
}

From source file:com.mirasense.demos.scan_using_zbar_in_fragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);/*from w w w.  ja  v  a2 s .c o  m*/

    View rootView = inflater.inflate(R.layout.main, container, false);

    MainActivity.global = 2;
    //   Toast.makeText(getActivity(), "call codebar", 30).show();

    getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    autoFocusHandler = new Handler();
    mCamera = getCameraInstance();

    /* Instance barcode scanner */
    scanner = new ImageScanner();
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);

    mPreview = new CameraPreview(getActivity(), mCamera, previewCb, autoFocusCB);
    FrameLayout preview = (FrameLayout) rootView.findViewById(R.id.cameraPreview);
    preview.addView(mPreview);

    scanText = (TextView) rootView.findViewById(R.id.scanText);

    scanButton = (Button) rootView.findViewById(R.id.ScanButton);

    scanimage = (ImageView) rootView.findViewById(R.id.Scanbarcodeimage);

    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (barcodeScanned) {
                barcodeScanned = false;
                scanText.setText("Scanning...");
                mCamera.setPreviewCallback(previewCb);
                mCamera.startPreview();
                previewing = true;
                mCamera.autoFocus(autoFocusCB);
            }
        }
    });

    return rootView;

}

From source file:com.geomarket.ui_logic.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout fl = new FrameLayout(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    fl.setLayoutParams(params);/* w  ww  . ja v  a2s .co  m*/

    switch (position) {

    case 0:
        View offerView = inflater.inflate(R.layout.activity_fragment_offer, null);
        fl.addView(offerView);
        Fragment offerFragment = new FragmentOffer();
        getFragmentManager().beginTransaction().replace(R.id.tab_offerview, offerFragment).commit();
        break;
    case 1:
        View favView = inflater.inflate(R.layout.activity_fragment_fav, null);
        fl.addView(favView);
        Fragment favFragment = new FragmentFav();
        getFragmentManager().beginTransaction().replace(R.id.tab_favview, favFragment).commit();
        break;
    case 2:
        View GoogleMapView = inflater.inflate(R.layout.activity_fragmentgooglemap, null);
        fl.addView(GoogleMapView);
        Fragment googlefragment = new Fragmentgooglemap();
        getFragmentManager().beginTransaction().replace(R.id.tab_googlemap, googlefragment).commit();
        break;
    }

    return fl;
}