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:org.bohrmeista.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 (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();/*from  ww w  . j a  v  a 2s . c  o 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.images.size() > 0) {
            imagePosts.add(post);
        }
    }

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

    // Select the right image
    int imageIndex = 0;
    for (Post post : imagePosts) {
        if (post.no == selectedId) {
            viewPager.setCurrentItem(imageIndex);
            onPageSelected(imageIndex);

            thumbList = (TwoWayView) findViewById(R.id.thumbList);
            thumbListAdapter = new ThumbListAdapter(this, post.images, imageIndex);
            thumbList.setAdapter(thumbListAdapter);
            thumbList.setVisibility(post.images.size() <= 1 ? View.GONE : View.VISIBLE);
            return;
        }
        imageIndex += post.images.size();
    }
}

From source file:fragment.MusicFragment.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);//  ww w.  ja va  2 s .  c  om

    switch (position) {
    case 0:
        View recorderView = inflater.inflate(R.layout.tab_recorder, null);
        fl.addView(recorderView);
        Fragment recorderFragment = new RecorderFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_recorder, recorderFragment).commit();
        break;
    case 1:
        View drumView = inflater.inflate(R.layout.tab_drum, null);
        fl.addView(drumView);
        Fragment drumFragment = new DrumFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_drum, drumFragment).commit();
        break;
    case 2:
        View saxophoneView = inflater.inflate(R.layout.tab_saxophone, null);
        fl.addView(saxophoneView);
        Fragment saxophoneFragment = new SaxophoneFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_saxophone, saxophoneFragment).commit();
        break;
    case 3:
        View handBellView = inflater.inflate(R.layout.tab_handbell, null);
        fl.addView(handBellView);
        Fragment handBellFragment = new HandBellFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_handbell, handBellFragment).commit();
        break;
    case 4:
        View harpView = inflater.inflate(R.layout.tab_harp, null);
        fl.addView(harpView);
        Fragment harpFragment = new HarpFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_harp, harpFragment).commit();
        break;
    }
    return fl;
}

From source file:com.TwentyCodes.android.IOIOTruck.CameraFragment.java

/**
 * (non-Javadoc)/*from www.j a  va  2  s  .  co  m*/
 * @see android.support.v4.app.Fragment#onViewCreated(android.view.View, android.os.Bundle)
 * @author ricky barrette
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.camera_fragment, container, false);

    /*
     * setup augmented preview overlay
     */
    FrameLayout fl = (FrameLayout) view.findViewById(R.id.camera_frame);
    mPreviewOverlay = new PreviewOverlay(this.getActivity());
    fl.addView(mPreviewOverlay);

    /*
     * setup camera preview      
     */
    mPreview = (SurfaceView) view.findViewById(R.id.cameraSurface);
    SurfaceHolder cameraHolder = mPreview.getHolder();
    cameraHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    cameraHolder.addCallback(new SurfaceHolder.Callback() {
        public void surfaceCreated(SurfaceHolder holder) {
            try {
                mCamera.setPreviewDisplay(holder);
                mCamera.startPreview();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        public void surfaceDestroyed(SurfaceHolder holder) {
        }

        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        }
    });

    return view;
}

From source file:com.facebook.react.testing.ReactAppTestActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(0, 0);//from w  ww.j ava2 s.  c  o m

    // We wrap screenshot layout in another FrameLayout in order to handle custom dimensions of the
    // screenshot view set through {@link #setScreenshotDimensions}
    FrameLayout rootView = new FrameLayout(this);
    setContentView(rootView);

    mScreenshotingFrameLayout = new ScreenshotingFrameLayout(this);
    mScreenshotingFrameLayout.setId(ROOT_VIEW_ID);
    rootView.addView(mScreenshotingFrameLayout);

    mReactRootView = new ReactRootView(this);
    mScreenshotingFrameLayout.addView(mReactRootView);
}

From source file:in.srain.demos.vector.BSDialog.java

private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
    final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(),
            R.layout.design_bottom_sheet_dialog, null);
    if (layoutResId != 0 && view == null) {
        view = getLayoutInflater().inflate(layoutResId, coordinator, false);
    }//  ww  w  .j a  va  2  s.c  o  m
    FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet);
    BottomSheetBehavior b = BottomSheetBehavior.from(bottomSheet);
    b.setBottomSheetCallback(mBottomSheetCallback);
    b.setPeekHeight(900);

    if (params == null) {
        bottomSheet.addView(view);
    } else {
        bottomSheet.addView(view, params);
    }
    // We treat the CoordinatorLayout as outside the dialog though it is technically inside
    if (shouldWindowCloseOnTouchOutside()) {
        final View finalView = view;
        coordinator.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (isShowing() && MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP
                        && !coordinator.isPointInChildBounds(finalView, (int) event.getX(),
                                (int) event.getY())) {
                    cancel();
                    return true;
                }
                return false;
            }
        });
    }
    return coordinator;
}

From source file:com.honeywell.printer.indicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;//from   w w w  . jav a 2 s .c o m
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
    }

    {// view
        final FrameLayout container = new FrameLayout(getContext());
        container.addView(tabView);
        final NumView badge = new NumView(getContext());
        badge.setId(index + ID_OFFSET);
        badge.setVisibility(View.GONE);
        container.addView(badge);
        mTabLayout.addView(container, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
    }
}

From source file:me.wizos.loread.view.webview.VideoImpl.java

public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    Activity mActivity;// w w w .  j av  a 2  s .  c  o  m
    if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) {
        return;
    }
    // ?
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    Window mWindow = mActivity.getWindow();
    Pair<Integer, Integer> mPair;
    // ????
    if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        mFlags.add(mPair);
    }

    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        mFlags.add(mPair);
    }

    if (videoView != null) {
        callback.onCustomViewHidden();
        return;
    }
    //        KLog.e("" + mWebView  + "   "  + videoParentView);
    if (mWebView != null) {
        mWebView.setVisibility(View.GONE);
    }

    if (videoParentView == null) {
        FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView();
        videoParentView = new FrameLayout(mActivity);
        videoParentView.setBackgroundColor(Color.BLACK);
        videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ?
        mDecorView.addView(videoParentView);
    }

    //        KLog.e("" + mWebView.getVisibility()  + "   "  + videoParentView);
    this.mCallback = callback;
    this.videoView = view;
    videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    videoParentView.setVisibility(View.VISIBLE);
    isPlaying = true;
}

From source file:com.mongolduu.android.ng.GDFragmentActivity.java

/**
 * <p>/*from   w w w .ja  va 2 s.  c o m*/
 * Set the activity content to an explicit view. This view is placed
 * directly into the activity's view hierarchy. It can itself be a complex
 * view hierarchy.
 * </p>
 * <p>
 * This method is an equivalent to setContentView(View) that automatically
 * wraps the given layout in an {@link ActionBarHost} if needed.
 * </p>
 * 
 * @param view The desired content to display.
 * @see #setActionBarContentView(int)
 * @see #setActionBarContentView(View, LayoutParams)
 */
public void setActionBarContentView(View view) {
    final FrameLayout contentView = getContentView();
    contentView.removeAllViews();
    contentView.addView(view);
}

From source file:com.silentcircle.contacts.list.ScDefaultContactBrowseListFragment.java

@Override
protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
    super.onCreateView(inflater, container);
    mCounterHeaderView = (TextView) getOwnView().findViewById(R.id.contacts_count);

    // Create an empty user profile header and hide it for now (it will be visible if the
    // contacts list will have no user profile).
    addEmptyUserProfileHeader(inflater);
    showEmptyUserProfile(false);/*from   www  .  j a  va  2s  .  com*/

    // Putting the header view inside a container will allow us to make
    // it invisible later. See checkHeaderViewVisibility()
    FrameLayout headerContainer = new FrameLayout(inflater.getContext());
    mSearchHeaderView = inflater.inflate(R.layout.search_header, null, false);
    headerContainer.addView(mSearchHeaderView);
    getListView().addHeaderView(headerContainer, null, false);
    checkHeaderViewVisibility();

    mSearchProgress = getOwnView().findViewById(R.id.search_progress);
    mSearchProgressText = (TextView) mSearchHeaderView.findViewById(R.id.totalContactsText);
}

From source file:com.chute.components.android.imagesharer.activity.DialogActivity.java

@Override
public View getWebView() {
    webView = new WebView(getApplicationContext());
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setWebViewClient(new BaseWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.setKeepScreenOn(true);//  ww  w. java 2s. c o m
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setUserAgentString(
            "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    FrameLayout frameLayout = new FrameLayout(getApplicationContext());
    frameLayout.setMinimumHeight(150);
    progressBar = new ProgressBar(getApplicationContext());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(100, 100);
    layoutParams.gravity = Gravity.CENTER;
    progressBar.setLayoutParams(layoutParams);
    frameLayout.addView(webView);
    frameLayout.addView(progressBar);
    return frameLayout;
}