List of usage examples for android.view ViewGroup addView
@Override public void addView(View child, LayoutParams params)
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { int layoutId; if (mExercise.needScrollableContainer()) { layoutId = R.layout.tutorial_lesson_fragment_scrollable; } else {//ww w. ja v a2 s .c om layoutId = R.layout.tutorial_lesson_fragment; } View view = inflater.inflate(layoutId, container, false); mDescription = (TextView) view.findViewById(R.id.description); mDescription.setText(mPage.getDescription()); TextView subTitle = (TextView) view.findViewById(R.id.part_subtitle); subTitle.setText(mPage.getSubtitle()); TextView currentPage = (TextView) view.findViewById(R.id.current_page); TextView next = (TextView) view.findViewById(R.id.next); if (mCurrentPage < mLesson.getPagesCount() - 1) { next.setText(R.string.tutorial_next); currentPage.setVisibility(View.VISIBLE); currentPage.setText( getString(R.string.tutorial_page_number_of, mCurrentPage + 1, mLesson.getPagesCount() - 1)); } else if (mTutorialController.getNextLesson(mLesson) == null) { next.setText(R.string.tutorial_home); } else { next.setText(R.string.tutorial_next_lesson); } next.setOnClickListener(this); View previous = view.findViewById(R.id.previous_page); previous.setOnClickListener(this); previous.setContentDescription(getString(R.string.tutorial_previous)); ViewGroup contentContainer = (ViewGroup) view.findViewById(R.id.practice_area); View contentView = mPage.getExercise().getContentView(inflater, contentContainer); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); contentContainer.addView(contentView, params); return view; }
From source file:com.example.ray.firstapp.bottombar.BottomBar.java
/** * Bind the BottomBar to your Activity, and inflate your layout here. * <p/>//from w w w . j a v a 2s . c om * Remember to also call {@link #onRestoreInstanceState(Bundle)} inside * of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state. * * @param activity an Activity to attach to. * @param savedInstanceState a Bundle for restoring the state on configuration change. * @return a BottomBar at the bottom of the screen. */ public static BottomBar attach(Activity activity, Bundle savedInstanceState) { BottomBar bottomBar = new BottomBar(activity); bottomBar.onRestoreInstanceState(savedInstanceState); ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content); View oldLayout = contentView.getChildAt(0); contentView.removeView(oldLayout); bottomBar.setPendingUserContentView(oldLayout); contentView.addView(bottomBar, 0); return bottomBar; }
From source file:com.example.ray.firstapp.bottombar.BottomBar.java
/** * Bind the BottomBar to the specified View's parent, and inflate * your layout there. Useful when the BottomBar overlaps some content * that shouldn't be overlapped./*from w w w .j av a2 s . co m*/ * <p/> * Remember to also call {@link #onRestoreInstanceState(Bundle)} inside * of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state. * * @param view a View, which parent we're going to attach to. * @param savedInstanceState a Bundle for restoring the state on configuration change. * @return a BottomBar at the bottom of the screen. */ public static BottomBar attach(View view, Bundle savedInstanceState) { BottomBar bottomBar = new BottomBar(view.getContext()); bottomBar.onRestoreInstanceState(savedInstanceState); ViewGroup contentView = (ViewGroup) view.getParent(); if (contentView != null) { View oldLayout = contentView.getChildAt(0); contentView.removeView(oldLayout); bottomBar.setPendingUserContentView(oldLayout); contentView.addView(bottomBar, 0); } else { bottomBar.setPendingUserContentView(view); } return bottomBar; }
From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) { // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0 LogUtils.d("showing Custom View"); // if a view already exists then immediately terminate the new one if (mCustomView != null) { callback.onCustomViewHidden();/* w w w. j a v a2 s.c o m*/ return; } // Store the view and its callback for later (to kill it properly) mCustomView = view; mCustomViewCallback = callback; // Add the custom view to its container. ViewGroup parent = (ViewGroup) this.getParent(); background = parent.getBackground(); parent.setBackground(new ColorDrawable(Color.BLACK)); parent.addView(view, COVER_SCREEN_GRAVITY_CENTER); // Hide the content view. this.setVisibility(View.GONE); // Finally show the custom view container. parent.setVisibility(View.VISIBLE); parent.bringToFront(); if (objects != null && objects.length > 0) { for (Object obj : objects) { if (obj instanceof View) { ((View) obj).setVisibility(View.GONE); } else if (obj instanceof Fragment) { ((Fragment) obj).getView().setVisibility(View.GONE); } } } ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); ((Activity) mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:android.support.v7.app.ActionBarActivityDelegateBase.java
@Override public void addContentView(View v, ViewGroup.LayoutParams lp) { ensureSubDecor();/*from w w w. ja va 2 s . c o m*/ if (mHasActionBar) { final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content); contentParent.addView(v, lp); } else { mActivity.superSetContentView(v, lp); } }
From source file:com.oprisnik.navdrawer.widget.NavDrawerLayout.java
public void setHeader(View header) { if (mNavdrawer != null) { ViewGroup contentHolder = (ViewGroup) mNavdrawer.findViewById(R.id.navdrawer_content_holder); if (mHeader != null) { // replace the header contentHolder.removeView(mHeader); }//from w w w . ja v a 2 s. com mHeader = header; if (mHeader != null) { mHasHeader = true; contentHolder.addView(mHeader, 0); } else { mHasHeader = false; } } }
From source file:com.google.android.apps.mytracks.fragments.ChartFragment.java
@SuppressWarnings("deprecation") @Override/* ww w . ja va2 s .c o m*/ public void onStart() { super.onStart(); ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout); LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.addView(chartView, layoutParams); }
From source file:com.epubtest.hxfy.epubtest.BasePDFPagerAdapter.java
@Override @SuppressWarnings("NewApi") public Object instantiateItem(ViewGroup container, int position) { View v = inflater.inflate(R.layout.view_pdf_page, container, false); ImageView iv = (ImageView) v.findViewById(R.id.imageView); if (renderer == null || getCount() < position) { return v; }//from ww w . j a v a 2 s .co m PdfRenderer.Page page = getPDFPage(renderer, position); Bitmap bitmap = bitmapContainer.get(position); page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY); page.close(); iv.setImageBitmap(bitmap); container.addView(v, 0); return v; }
From source file:android.support.v7.app.ActionBarActivityDelegateBase.java
@Override public void setContentView(View v, ViewGroup.LayoutParams lp) { ensureSubDecor();/*w w w . j a v a 2 s . com*/ if (mHasActionBar) { final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content); contentParent.removeAllViews(); contentParent.addView(v, lp); } else { mActivity.superSetContentView(v, lp); } }
From source file:com.github.barteksc.pdfviewpager.adapter.PDFPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View v = inflater.inflate(R.layout.view_pdf_page, container, false); ImageView iv = (ImageView) v.findViewById(R.id.imageView); if (!pdfiumReady() || getCount() < position) return v; executeRenderTask(iv, position, new PdfRenderPageAsyncTask.OnPdfPageRenderListener() { @Override/* w ww . j av a 2 s. c o m*/ public void onPageRendered(int position, ImageView imageView, Bitmap bitmap) { bitmaps.put(position, new WeakReference<>(bitmap)); } }); container.addView(v, 0); return v; }