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

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.lee.sdk.widget.viewpager.PagerAdapterImpl.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = mViewPool.get();//from w w  w .j a  v  a 2  s  .c om
    if (null == view) {
        if (DEBUG) {
            Log.e(TAG, "instantiateItem    create view!!!, position = " + position);
        }
        view = onInstantiateItem(container, position);
    }

    mViewList.put(position, view);
    container.addView(view);

    // ?View
    onConfigItem(view, position);

    return view;
}

From source file:com.agna.setmaster.ui.screen.profile.condition.ConditionSetPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ConditionSetView conditionSetView = (ConditionSetView) LayoutInflater.from(container.getContext())
            .inflate(R.layout.condition_set_view, container, false);
    conditionSetView.showConditionSet(conditionSets.get(position));
    conditionSetView.setOnConditionActionListener(innerOnConditionActionListener);
    container.addView(conditionSetView);
    return conditionSetView;
}

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);
            }/*  w w  w  .  j a v a  2s.  c o  m*/
        } 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.lsjwzh.widget.recyclerviewpagerdeomo.ViewPagerFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mViewPager = (ViewPager) view.findViewById(R.id.list);
    mViewPager.setAdapter(new PagerAdapter() {
        @Override/*from  w  w w .j a va  2 s  .c o  m*/
        public int getCount() {
            return 100;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            final View view = LayoutInflater.from(getActivity()).inflate(R.layout.item, container, false);
            ((TextView) view.findViewById(R.id.title)).setText(position + "");
            view.setTag("" + position);
            container.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if (object != null && object instanceof View) {
                container.removeView((View) object);
            }
        }

        @Override
        public int getItemPosition(Object object) {
            if (object instanceof View) {
                return Integer.valueOf(((View) object).getTag().toString());
            }
            return super.getItemPosition(object);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }
    });
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            updateState(state);
        }
    });

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(RecyclerView.SCROLL_STATE_IDLE);
}

From source file:com.pimp.instincts.adapters.GalleryViewPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = inflater.inflate(R.layout.item_view_pager_gallery, container, false);

    view.setTag(R.id.index, position);//  w w w  .  j a v  a2 s.  c  o m
    ImageView image = (ImageView) view.findViewById(R.id.gallery_image);
    Picasso.with(context).load("http://ssninstincts.org.in/img/gallery/big/" + (position + 1) + ".jpg")
            .into(image);

    container.addView(view);

    return view;
}

From source file:com.yanzhenjie.recyclerview.swipe.SwipeAdapterWrapper.java

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (mHeaderViews.get(viewType) != null) {
        return new ViewHolder(mHeaderViews.get(viewType));
    } else if (mFootViews.get(viewType) != null) {
        return new ViewHolder(mFootViews.get(viewType));
    }// w w  w. j av  a2  s  .  c o m
    final RecyclerView.ViewHolder viewHolder = mAdapter.onCreateViewHolder(parent, viewType);

    if (mSwipeItemClickListener != null) {
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSwipeItemClickListener.onItemClick(v, viewHolder.getAdapterPosition());
            }
        });
    }
    if (mSwipeItemLongClickListener != null) {
        viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                mSwipeItemLongClickListener.onItemLongClick(v, viewHolder.getAdapterPosition());
                return true;
            }
        });
    }

    if (mSwipeMenuCreator == null)
        return viewHolder;

    final SwipeMenuLayout swipeMenuLayout = (SwipeMenuLayout) mInflater
            .inflate(R.layout.recycler_swipe_view_item, parent, false);
    SwipeMenu swipeLeftMenu = new SwipeMenu(swipeMenuLayout, viewType);
    SwipeMenu swipeRightMenu = new SwipeMenu(swipeMenuLayout, viewType);

    mSwipeMenuCreator.onCreateMenu(swipeLeftMenu, swipeRightMenu, viewType);

    int leftMenuCount = swipeLeftMenu.getMenuItems().size();
    if (leftMenuCount > 0) {
        SwipeMenuView swipeLeftMenuView = (SwipeMenuView) swipeMenuLayout.findViewById(R.id.swipe_left);
        // noinspection WrongConstant
        swipeLeftMenuView.setOrientation(swipeLeftMenu.getOrientation());
        swipeLeftMenuView.createMenu(swipeLeftMenu, swipeMenuLayout, mSwipeMenuItemClickListener,
                SwipeMenuRecyclerView.LEFT_DIRECTION);
    }

    int rightMenuCount = swipeRightMenu.getMenuItems().size();
    if (rightMenuCount > 0) {
        SwipeMenuView swipeRightMenuView = (SwipeMenuView) swipeMenuLayout.findViewById(R.id.swipe_right);
        // noinspection WrongConstant
        swipeRightMenuView.setOrientation(swipeRightMenu.getOrientation());
        swipeRightMenuView.createMenu(swipeRightMenu, swipeMenuLayout, mSwipeMenuItemClickListener,
                SwipeMenuRecyclerView.RIGHT_DIRECTION);
    }

    ViewGroup viewGroup = (ViewGroup) swipeMenuLayout.findViewById(R.id.swipe_content);
    viewGroup.addView(viewHolder.itemView);

    try {
        Field itemView = getSupperClass(viewHolder.getClass()).getDeclaredField("itemView");
        if (!itemView.isAccessible())
            itemView.setAccessible(true);
        itemView.set(viewHolder, swipeMenuLayout);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return viewHolder;
}

From source file:com.baruckis.nanodegree.spotifystreamer.fragments.ArtistTracksListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_artist_tracks_list, container, false);

    mInfoView = (InfoView) rootView.findViewById(R.id.info_view);
    ViewGroup contentLayout = (ViewGroup) rootView.findViewById(R.id.content_layout);

    contentLayout.addView(view);
    // after add info view goes behind and becomes unclickable, so that's why it is moved to front.
    mInfoView.bringToFront();//from   www.ja v  a 2s.  c om

    return rootView;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.JoinNotificationObj.java

@Override
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    TextView valueTV = new TextView(context);
    valueTV.setText("I'm here!");
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    frame.addView(valueTV);
}

From source file:com.flexible.flexibleadapter.helpers.StickyHeaderHelper.java

private void initStickyHeadersHolder() {
    if (mStickyHolderLayout == null) {
        // Create stickyContainer for shadow elevation
        FrameLayout stickyContainer = createContainer(mRecyclerView.getMeasuredWidth(),
                ViewGroup.LayoutParams.WRAP_CONTENT);
        ViewGroup oldParentLayout = getParent(mRecyclerView);
        oldParentLayout.addView(stickyContainer);
        // Initialize Holder Layout
        mStickyHolderLayout = (ViewGroup) LayoutInflater.from(mRecyclerView.getContext())
                .inflate(R.layout.sticky_header_layout, stickyContainer);
        if (FlexibleAdapter.DEBUG)
            Log.i(TAG, "Default StickyHolderLayout initialized");
    } else if (FlexibleAdapter.DEBUG) {
        Log.i(TAG, "User defined StickyHolderLayout initialized");
    }//from  www  . j av a  2 s . c  o m
    // Show sticky header if exists already
    updateOrClearHeader(false);
}

From source file:core.september.speechreminder.activities.SpeechReminderActivity.java

@Override
public void onResume() {
    super.onResume();
    //setContentView(R.layout.main);

    RevMobAdsListener listener = new RevMobAdsListener() {
        public void onRevMobAdReceived() {
            Log.i("[RevMob]", "onAdReceived");
        }/*from  w  w  w  .j  ava2s .c  om*/

        public void onRevMobAdNotReceived(String message) {
        } // you can hide the More Games Button here

        public void onRevMobAdDisplayed() {
        }

        public void onRevMobAdDismiss() {
        }

        public void onRevMobAdClicked() {
        }
    };

    RevMob revmob = RevMob.start(this, Config.REVMOB_APP_ID);
    RevMobBanner banner = revmob.createBanner(this);
    fullscreen = revmob.createFullscreen(this, listener); // pre-load it without showing it
    if (findViewById(R.id.banner) != null) {
        ViewGroup view = (ViewGroup) findViewById(R.id.banner);
        view.addView(banner);
    }

    link = revmob.createAdLink(this, listener);

}