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.devspark.progressfragment.ProgressFragment.java

/**
 * Set the content view to an explicit view. If the content view was installed earlier,
 * the content will be replaced with a new view.
 *
 * @param view The desired content to display. Value can't be null.
 * @see #setContentView(int)/*  w w w  . j  a va2  s  .co  m*/
 * @see #getContentView()
 */
public void setContentView(View view) {
    ensureContent();
    if (view == null) {
        throw new IllegalArgumentException("Content view can't be null");
    }
    if (mContentContainer instanceof ViewGroup) {
        ViewGroup contentContainer = (ViewGroup) mContentContainer;
        if (mContentView == null) {
            contentContainer.addView(view);
        } else {
            int index = contentContainer.indexOfChild(mContentView);
            // replace content view
            contentContainer.removeView(mContentView);
            contentContainer.addView(view, index);
        }
        mContentView = view;
    } else {
        throw new IllegalStateException("Can't be used with a custom content view");
    }
}

From source file:com.jakewharton.utils.RecyclingPagerAdapter.java

@Override
public final Object instantiateItem(ViewGroup container, int position) {
    int viewType = getItemViewType(position);
    View view = null;//from w  ww.  j  a  v  a2s.  co  m
    if (viewType != IGNORE_ITEM_VIEW_TYPE) {
        view = recycleBin.getScrapView(position, viewType);
    }
    view = getView(position, view, container);
    container.addView(view);
    return view;
}

From source file:com.manaschaudhari.android_mvvm.adapters.ViewPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ViewModel vm = latestViewModels.get(position);
    int layoutId = viewProvider.getView(vm);
    ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), layoutId,
            container, false);/*from   w  w  w. j a v a 2  s.  c  om*/
    binder.bind(binding, vm);
    container.addView(binding.getRoot());
    return binding;
}

From source file:at.alladin.rmbt.android.adapter.result.QoSTestDetailPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final Context context = container.getContext();
    View view = null;//from   w  ww. j  a  va2 s .  co m
    //view = new QoSCategoryView(context, activity, results.getTestDescMap().get(key), resultMap.get(key), descMap.get(key));
    view = new QoSTestDetailView(context, activity, resultList.get(position), descList);
    container.addView(view);
    return view;
}

From source file:dev.drsoran.moloko.fragments.TagCloudFragment.java

private void showEmptyView() {
    final SherlockFragmentActivity activity = getSherlockActivity();
    final View noElementsView = activity.getLayoutInflater().inflate(R.layout.app_no_elements, null);
    UIUtils.setNoElementsText(noElementsView, R.string.tagcloud_no_tags);

    final ViewGroup tagContainer = (ViewGroup) activity.findViewById(R.id.tagcloud_container);
    tagContainer.addView(noElementsView);
}

From source file:com.jtechme.apphub.privileged.views.InstallConfirmActivity.java

private void startInstallConfirm() {

    final Drawable appIcon = mAppDiff.mPkgInfo.applicationInfo.loadIcon(mPm);
    final String appLabel = (String) mAppDiff.mPkgInfo.applicationInfo.loadLabel(mPm);

    View appSnippet = findViewById(R.id.app_snippet);
    ((ImageView) appSnippet.findViewById(R.id.app_icon)).setImageDrawable(appIcon);
    ((TextView) appSnippet.findViewById(R.id.app_name)).setText(appLabel);

    TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
    tabHost.setup();//from   w w w.ja v a 2  s  .  com
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager);
    adapter.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
        }
    });

    boolean permVisible = false;
    mScrollView = null;
    mOkCanInstall = false;
    int msg = 0;
    AppSecurityPermissions perms = new AppSecurityPermissions(this, mAppDiff.mPkgInfo);
    if (mAppDiff.mInstalledAppInfo != null) {
        msg = (mAppDiff.mInstalledAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                ? R.string.install_confirm_update_system
                : R.string.install_confirm_update;
        mScrollView = new CaffeinatedScrollView(this);
        mScrollView.setFillViewport(true);
        final boolean newPermissionsFound = perms.getPermissionCount(AppSecurityPermissions.WHICH_NEW) > 0;
        if (newPermissionsFound) {
            permVisible = true;
            mScrollView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_NEW));
        } else {
            throw new RuntimeException(
                    "This should not happen. No new permissions were found but InstallConfirmActivity has been started!");
        }
        adapter.addTab(tabHost.newTabSpec(TAB_ID_NEW).setIndicator(getText(R.string.newPerms)), mScrollView);
    } else {
        findViewById(R.id.tabscontainer).setVisibility(View.GONE);
        findViewById(R.id.divider).setVisibility(View.VISIBLE);
    }
    final int np = perms.getPermissionCount(AppSecurityPermissions.WHICH_PERSONAL);
    final int nd = perms.getPermissionCount(AppSecurityPermissions.WHICH_DEVICE);
    if (np > 0 || nd > 0) {
        permVisible = true;
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View root = inflater.inflate(R.layout.permissions_list, null);
        if (mScrollView == null) {
            mScrollView = (CaffeinatedScrollView) root.findViewById(R.id.scrollview);
        }
        final ViewGroup privacyList = (ViewGroup) root.findViewById(R.id.privacylist);
        if (np > 0) {
            privacyList.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_PERSONAL));
        } else {
            privacyList.setVisibility(View.GONE);
        }
        final ViewGroup deviceList = (ViewGroup) root.findViewById(R.id.devicelist);
        if (nd > 0) {
            deviceList.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_DEVICE));
        } else {
            root.findViewById(R.id.devicelist).setVisibility(View.GONE);
        }
        adapter.addTab(tabHost.newTabSpec(TAB_ID_ALL).setIndicator(getText(R.string.allPerms)), root);
    }

    if (!permVisible) {
        if (mAppDiff.mInstalledAppInfo != null) {
            // This is an update to an application, but there are no
            // permissions at all.
            msg = (mAppDiff.mInstalledAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                    ? R.string.install_confirm_update_system_no_perms
                    : R.string.install_confirm_update_no_perms;
        } else {
            // This is a new application with no permissions.
            msg = R.string.install_confirm_no_perms;
        }
        tabHost.setVisibility(View.GONE);
        findViewById(R.id.filler).setVisibility(View.VISIBLE);
        findViewById(R.id.divider).setVisibility(View.GONE);
        mScrollView = null;
    }
    if (msg != 0) {
        ((TextView) findViewById(R.id.install_confirm)).setText(msg);
    }
    mInstallConfirm.setVisibility(View.VISIBLE);
    mOk = (Button) findViewById(R.id.ok_button);
    mCancel = (Button) findViewById(R.id.cancel_button);
    mOk.setOnClickListener(this);
    mCancel.setOnClickListener(this);
    if (mScrollView == null) {
        // There is nothing to scroll view, so the ok button is immediately
        // set to install.
        mOk.setText(R.string.menu_install);
        mOkCanInstall = true;
    } else {
        mScrollView.setFullScrollAction(new Runnable() {
            @Override
            public void run() {
                mOk.setText(R.string.menu_install);
                mOkCanInstall = true;
            }
        });
    }
}

From source file:com.alex.view.loop.BannerPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.banner_item, container, false);
    ImageView imageView = (ImageView) view.findViewById(R.id.iv_banner_item);
    // ???//from w  w w . j  a  va2 s .c  om
    position %= pictureList.size();
    imageView.setImageResource(pictureList.get(position));
    container.addView(view);
    return view;
}

From source file:com.baruckis.nanodegree.spotifystreamer.fragments.ArtistsListFragment.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_artists_list, container, false);

    mSearchEditText = (EditText) rootView.findViewById(R.id.search_edit_text);
    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  w ww  .  j av  a2 s. c  om

    return rootView;
}

From source file:com.netease.hearttouch.htimagepicker.core.view.photoview.ViewPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    // ??view???viewnull
    View view = getView(pullViewFromPool(), position);
    //        resetPhotoViews();

    // viewdestroyItem
    mPageViews.put(position, view);//  ww  w.j av  a  2s . c om
    // view pager
    container.addView(view);

    return view;
}

From source file:com.mifos.mifosxdroid.online.SurveyQuestionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_survey_question, container, false);
    ButterKnife.inject(this, view);
    thiscontext = container.getContext();
    mQuestionDatas = (new Gson()).fromJson(getArguments().getString(QUESTION_DATA), QuestionDatas.class);
    mScorecardValues = new ScorecardValues();

    tv_question.setText(mQuestionDatas.getText());

    ViewGroup hourButtonLayout = (ViewGroup) view.findViewById(R.id.radio1);
    for (int i = 0; i < mQuestionDatas.getResponseDatas().size(); i++) {
        button1 = new RadioButton(thiscontext);
        button1.setId(i);//  w  w  w.  j  a  va  2  s .  c  o  m
        button1.setText(mQuestionDatas.getResponseDatas().get(i).getText());
        hourButtonLayout.addView(button1);
        radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup mRadioGroup2, int checkedId2) {
                for (int j = 0; j < mRadioGroup2.getChildCount(); j++) {
                    btn = (RadioButton) mRadioGroup2.getChildAt(j);
                    int t = mRadioGroup2.getId();
                    Log.d(LOG_TAG, "" + t);

                    if (btn.getId() == checkedId2) {
                        answer = btn.getText().toString();
                        mScorecardValues.setQuestionId(mQuestionDatas.getQuestionId());
                        mScorecardValues
                                .setResponseId(mQuestionDatas.getResponseDatas().get(j).getResponseId());
                        mScorecardValues.setValue(mQuestionDatas.getResponseDatas().get(j).getValue());
                        mCallback.answer(mScorecardValues);
                        Log.d(LOG_TAG,
                                "Q R V" + mQuestionDatas.getQuestionId() + " "
                                        + mQuestionDatas.getResponseDatas().get(j).getResponseId() + " "
                                        + mQuestionDatas.getResponseDatas().get(j).getValue());
                        return;
                    }
                }
            }
        });
    }

    return view;
}