Example usage for android.view ViewGroup addView

List of usage examples for android.view ViewGroup addView

Introduction

In this page you can find the example usage for android.view ViewGroup addView.

Prototype

@Override
public void addView(View child, LayoutParams params) 

Source Link

Document

Adds a child view with the specified layout parameters.

Usage

From source file:com.commonsware.android.preso.decktastic.SlidesAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ImageView page = new ImageView(ctxt);
    ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);

    container.addView(page, p);

    Picasso.with(ctxt).load(getSlideImageUri(position)).into(page);

    return (page);
}

From source file:com.roxbyte.formality.adapter.DefaultPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater layoutInflater = (LayoutInflater) container.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = layoutInflater.inflate(resources[position], null);
    container.addView(view, 0);
    return view;//from  w w  w. j av  a2s  . c  om
}

From source file:bottombar.BottomBarBadge.java

void removeFromTab(BottomBarTab tab) {
    BadgeContainer badgeAndTabContainer = (BadgeContainer) getParent();
    ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent();

    badgeAndTabContainer.removeView(tab);
    originalTabContainer.removeView(badgeAndTabContainer);
    originalTabContainer.addView(tab, tab.getIndexInTabContainer());
}

From source file:com.intel.xdk.display.Display.java

@JavascriptInterface
public void startAR() {
    arView = CameraPreview.newInstance(activity.getApplicationContext());
    arView.setVisibility(View.INVISIBLE);

    arView.height = 100;// w ww .  j a  va2  s  .c  o m
    arView.width = 100;

    //no way to get current background color?
    arView.setBackgroundColor(Color.TRANSPARENT);

    SurfaceHolder sfhTrackHolder = arView.getHolder();
    sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);
    sfhTrackHolder.setKeepScreenOn(true);
    sfhTrackHolder.setFixedSize(100, 100);

    activity.runOnUiThread(new Runnable() {
        public void run() {

            //activity.addContentView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
            //activity.addContentView(arView, new LinearLayout.LayoutParams(400, 500, 0.0F));
            ViewGroup rootView = (ViewGroup) webView.getParent().getParent();
            rootView.addView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT));
            rootView.bringChildToFront((View) webView.getParent());

            arView.setVisibility(View.VISIBLE);
            arView.showCamera();
            webView.bringToFront();
            webView.setBackgroundColor(0x00000000);
            LinearLayout ll = (LinearLayout) webView.getParent();
            ll.setBackgroundColor(0x00000000);

            View activityView = activity.getCurrentFocus();
        }
    });
}

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

void removeFromTab(BottomBarTab tab) {
    FrameLayout badgeAndTabContainer = (FrameLayout) getParent();
    ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent();

    badgeAndTabContainer.removeView(tab);
    originalTabContainer.removeView(badgeAndTabContainer);
    originalTabContainer.addView(tab, tab.getIndexInTabContainer());
}

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  w w  w . j  a  va2s .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:com.putao.widget.touchgallery.GalleryWidget.FilePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup collection, int position) {
    final FileTouchImageView iv = new FileTouchImageView(mContext);
    iv.setUrl(mResources.get(position));
    iv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    collection.addView(iv, 0);
    return iv;//from  w w  w  .j a  v a2  s .com
}

From source file:com.example.android.animationsdemo.BoardFragment.java

public void addItem(View view) {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View newCard = inflater.inflate(R.layout.new_card_layout, null, false);
    newCard.setTag("newCard");
    ViewGroup parentCol = (ViewGroup) view.getParent();
    ViewGroup svCol = (ViewGroup) parentCol.getChildAt(parentCol.getChildCount() - 1);
    ViewGroup containerCol = (ViewGroup) svCol.getChildAt(0);
    View check = containerCol.findViewWithTag("newCard");
    if (check == null)
        containerCol.addView(newCard, 0);
    else//from   w  w  w . j  a  va 2s. c  o  m
        containerCol.removeView(check);
    ImageView save = (ImageView) newCard.findViewById(R.id.saveNewCard);
    final EditText title = (EditText) newCard.findViewById(R.id.newCardTitle);
    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view1) {
            if (isEmpty(title))
                Toast.makeText(context, "Please enter a title", Toast.LENGTH_SHORT).show();
            else {
                query = "";
                pager.getAdapter().notifyDataSetChanged();
                InputMethodManager imm = (InputMethodManager) context
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
            } //
        }
    });
}

From source file:com.jana.android.ui.impl.viewmodel.ImagePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {

    View view = getItem(position);

    while (mViewsList.size() <= position) {
        mViewsList.add(null);/*from w  w  w  . jav a 2s.c  o m*/
    }

    mViewsList.set(position, view);

    container.addView(view, 0);

    return view;
}

From source file:com.xengar.android.stocktracker.ui.SettingsActivity.java

/**
 * Set up the {@link android.support.v7.widget.Toolbar}, if the API is available.
 *//*from w w w.j a v a2s  . co m*/
private void setupToolBar() {
    Toolbar toolbar;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewGroup root = (ViewGroup) findViewById(android.R.id.list).getParent().getParent().getParent();
        toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.view_toolbar, root, false);
        root.addView(toolbar, 0);
    } else {
        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
        ListView content = (ListView) root.getChildAt(0);
        root.removeAllViews();
        toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.view_toolbar, root, false);
        int height;
        TypedValue tv = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
            height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        } else {
            height = toolbar.getHeight();
        }
        content.setPadding(0, height, 0, 0);
        root.addView(content);
        root.addView(toolbar);
    }
    toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}