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.zhongsou.souyue.adapter.GalleryNewsPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup collection, int position) {
    if (RELATE_TAG.equals(getItem(position))) {
        //??/*from  w ww.j a  v a2s .co m*/
        View lastPage = View.inflate(mContext, R.layout.gallerynews_activity_recommend, null);
        initRecommendView(lastPage);
        collection.addView(lastPage);
        return lastPage;
    } else {
        //???
        UrlTouchImageView iv = new UrlTouchImageView(mContext);
        iv.setDownLoadLinstener((DownLoadLinstener) mContext);
        iv.setBgUrl(mNewsList.getContent().get(position).getUrl());
        collection.addView(iv, 0);
        return iv;
    }
}

From source file:com.seal.ui.fragments.StartPageFragment.java

private void iniListener() {

    if (mUIManager != null) {
        mStartListViewAdapter = new ExpandableListViewAdapter(getActivity(), mUIManager);
        mStartListView.setAdapter(mStartListViewAdapter);
        mStartListView.expandGroup(0);/*from   w w w . j  av  a  2  s  .co m*/
        mStartListView.expandGroup(1);
        mStartListView.expandGroup(2);
    }
    futureWeatherGrid.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.weather.com.cn");
        }
    });

    start_viewpager.setAdapter(new PagerAdapter() {
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            container.addView(views[position]);
            return views[position];
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {

            container.removeView(views[position]);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getCount() {
            return views.length;
        }
    });
    start_viewpager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // TODO Auto-generated method stub
            switch (position) {
            case 0:
                indicator_1.setImageResource(R.drawable.ic_pageindicator_current);
                indicator_2.setImageResource(R.drawable.ic_pageindicator_default);
                break;
            case 1:
                indicator_1.setImageResource(R.drawable.ic_pageindicator_default);
                indicator_2.setImageResource(R.drawable.ic_pageindicator_current);
                break;
            }
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            // TODO Auto-generated method stub

        }
    });
    weatherRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (!TextUtils.isEmpty(currentCity)) {
                getBeautyData(currentCity);
            }
        }
    });
    news.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.toutiao.com");
        }
    });
    nav.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.hao123.com");
        }
    });
    baidu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.baidu.com");
        }
    });
    shipin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mUIManager.loadUrl("http://m.video.baidu.com");
        }
    });
}

From source file:com.liferay.mobile.screens.viewsets.defaultviews.ddl.pager.DDLFormPagerViewAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    Context context = container.getContext();

    Field field = fields.get(position);
    Field.EditorType type = field.getEditorType();
    int layoutId = layoutIds.get(type);

    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(layoutId, container, false);

    DDLFieldViewModel viewModel = (DDLFieldViewModel) view;
    viewModel.setField(field);//from w  ww .  j  a v a 2 s .  c om

    container.addView(view);

    return view;
}

From source file:co.codecrunch.musicplayerlite.adapter.SongsPagerAdapter.java

@Override
public View instantiateItem(ViewGroup container, final int position) {
    View infV = inflater.inflate(R.layout.inflate_albumart_pager, container, false);
    ImageView artImage = (ImageView) infV.findViewById(R.id.image_songAlbumbg_mid);
    String contentURI = "content://media/external/audio/media/" + MusicPreferance.playlist.get(position).getId()
            + "/albumart";
    imageLoader.displayImage(contentURI, artImage, options, animateFirstListener);
    container.addView(infV);
    return infV;/* ww w  . j  a  va  2s  .  com*/
}

From source file:com.dabay6.libraries.androidshared.ui.fragments.LoadingFragment.java

/**
 * @param view/*  ww  w .j  av  a 2 s  . com*/
 */
public void setContentView(final View view) {
    afterViews();

    if (view == null) {
        throw new IllegalArgumentException("Content view can't be null");
    }

    if (contentContainer instanceof ViewGroup) {
        final ViewGroup container = (ViewGroup) contentContainer;

        if (content == null) {
            container.addView(view);
        } else {
            final int index = container.indexOfChild(content);

            // replace content view
            container.removeView(content);
            container.addView(view, index);
        }

        content = view;
    } else {
        throw new IllegalStateException("Can't be used with a custom content view");
    }
}

From source file:com.fragmentmaster.app.FragmentMasterImpl.java

@Override
protected void performInstall(ViewGroup container) {
    mAdapter = new FragmentsAdapter();
    mViewPager = new FragmentMasterPager(this);
    mViewPager.setId(FRAGMENT_CONTAINER_ID);
    mViewPager.setOffscreenPageLimit(Integer.MAX_VALUE);
    mViewPager.setAdapter(mAdapter);// ww  w  . ja  v a  2 s  .c  o m
    mViewPager.setOnPageChangeListener(mOnPageChangeListener);

    container.addView(mViewPager);
}

From source file:com.example.android.pantry.scanner.BarcodeScannerActivity.java

@Override
protected void onCreate(Bundle state) {
    super.onCreate(state);
    if (state != null) {
        mFlash = state.getBoolean(FLASH_STATE, false);
        mAutoFocus = state.getBoolean(AUTO_FOCUS_STATE, true);
        mSelectedIndices = state.getIntegerArrayList(SELECTED_FORMATS);
        mCameraId = state.getInt(CAMERA_ID, -1);
    } else {//from  w  w  w .j  a v a2s  . c  o  m
        mFlash = false;
        mAutoFocus = true;
        mSelectedIndices = null;
        mCameraId = -1;
    }

    setContentView(R.layout.activity_simple_scanner);
    setupToolbar();

    ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
    mScannerView = new ZXingScannerView(this);
    setupFormats();
    contentFrame.addView(mScannerView);
}

From source file:com.farukcankaya.rtlviewpagerindicatorsample.ColorPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_color_pager, container,
            false);// w ww  . j a va  2  s . c o  m
    TextView numberTextView = (TextView) view.findViewById(R.id.number);
    TextView titleTextView = (TextView) view.findViewById(R.id.title);

    view.setBackgroundColor(colors[position]);
    numberTextView.setText(String.valueOf(position));
    titleTextView.setText(titles[position]);

    container.addView(view);
    return view;
}

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

@Override
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from w w w.  j a  va 2  s  .  c om*/

    TextView valueTV = new TextView(context);
    valueTV.setText("Join me in '" + content.optString(GROUP_NAME) + "'");
    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.android.ted.sample.viewpager.MainPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;/*  w w w  .j  a v a2 s  .  co  m*/
    Girl girl = mAllGirlList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Girl) {
            if (tag.equals(girl)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    Glide.with(mContext).load(girl.getImageUrl()).into(imageView);
    imageView.setTag(girl);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}