List of usage examples for android.view ViewGroup addView
public void addView(View child)
Adds a child view.
From source file:com.ubiLive.GameCloud.activity.MainActivity.java
private EulaUI initEulaPage(ViewGroup root) { SharedPreferences sharedpreferences = PreferenceManager.openPrference(this, Constants.PREFERENCE_DB); boolean enableEula = !PreferenceManager.getBooleanValue(sharedpreferences, Constants.EULASTATUS); EulaUI eulaUI = null;//from w w w .j a v a2 s . c o m if (enableEula) { mVideoView = initVideoPage(root); eulaUI = new EulaUI(this, Utils.getScreenWidth(this), Utils.getScreenHeight(this)); eulaUI.getAcceptButton().setOnClickListener(mEulaUIOnClickListener); root.addView(eulaUI); if (mGCParse != null) { mGCParse.trackEvent(GCParse.TRACKEVENT_EULASHOW, null); } } return eulaUI; }
From source file:com.android.fastexample.adapter.FragmentViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { Fragment fragment = fragments.get(position); if (!fragment.isAdded()) { // fragmentadded FragmentTransaction ft = fragmentManager.beginTransaction(); ft.add(fragment, fragment.getClass().getSimpleName()); ft.commit();/* w w w . j av a 2s .c o m*/ /** * FragmentTransaction.commit()??FragmentTransaction? * ?? * ????? * ????? */ fragmentManager.executePendingTransactions(); } if (fragment.getView().getParent() == null) { container.addView(fragment.getView()); // viewpager } return fragment.getView(); }
From source file:com.tmall.ultraviewpager.sample.UltraPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext()) .inflate(R.layout.layout_child, null); //new LinearLayout(container.getContext()); TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview); textView.setText(position + ""); linearLayout.setId(R.id.item_id);//from w ww .jav a2 s. c o m switch (position) { case 0: linearLayout.setBackgroundColor(Color.parseColor("#2196F3")); break; case 1: linearLayout.setBackgroundColor(Color.parseColor("#673AB7")); break; case 2: linearLayout.setBackgroundColor(Color.parseColor("#009688")); break; case 3: linearLayout.setBackgroundColor(Color.parseColor("#607D8B")); break; case 4: linearLayout.setBackgroundColor(Color.parseColor("#F44336")); break; } container.addView(linearLayout); // linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics()); // linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics()); return linearLayout; }
From source file:com.pacific.adapter.BasePagerAdapter2.java
@Override public Object instantiateItem(ViewGroup container, int position) { H holder;/* ww w .j a v a 2s.co m*/ T item = get(position); View convertView = cacheViews.poll(); if (convertView == null) { if (inflater == null) { inflater = LayoutInflater.from(container.getContext()); } convertView = inflater.inflate(item.getLayout(), container, false); holder = createViewHolder(convertView); convertView.setTag(R.integer.adapter_holder, holder); } else { holder = (H) convertView.getTag(R.integer.adapter_holder); } holder.setCurrentPosition(position); holder.setSize(getCount()); holder.setCurrentItem(item); item.bind(holder); container.addView(convertView); return convertView; }
From source file:com.activiti.android.ui.form.FormManager.java
/** * Works for 1.1 Form Definition/*from ww w. j ava 2 s. c om*/ * * @param li * @param isEdition */ protected void generateForm11(LayoutInflater li, boolean isEdition) { ViewGroup rootView = (ViewGroup) li.inflate(R.layout.form_root, null); ViewGroup hookView = rootView; fieldsIndex = new HashMap<>(data.getFields().size()); boolean createGroup = true; ViewGroup groupRoot = null; BaseField field; for (FormFieldRepresentation fieldData : data.getFields()) { if (FormFieldTypes.GROUP.equals(fieldData.getType())) { if (groupRoot != null) { rootView.addView(groupRoot); } // Header field = generateField(fieldData, rootView, isEdition); createGroup = true; groupRoot = null; } else { if (createGroup) { // Create groupView groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null); hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container); createGroup = false; } // Normal Field field = generateField(fieldData, hookView, isEdition); } fieldsOrderIndex.add(field); fieldsIndex.put(fieldData.getId(), field); // Mark All fields in edition mode if (isEdition) { // Mark required Field if (fieldData.isRequired()) { mandatoryFields.add(field); } if (fieldData instanceof RestFieldRepresentation) { field.setFragment(fr); } } // If requires fragment for pickers. if (field.isPickerRequired()) { field.setFragment(fr); } } // Now time to evaluate everyone evaluateViews(); // Add Container to root ? if (groupRoot != null) { rootView.addView(groupRoot); } vRoot.addView(rootView); // OUTCOME if (!isEdition) { return; } View vr; if (data.getOutcomes() == null || data.getOutcomes().size() == 0) { outcomeIndex = new HashMap<>(1); vr = generateOutcome(rootView, getActivity().getString(R.string.form_default_outcome_complete), li); outcomeIndex.put(getActivity().getString(R.string.form_default_outcome_complete), vr); } else { outcomeIndex = new HashMap<>(data.getOutcomes().size()); for (FormOutcomeRepresentation outcomeData : data.getOutcomes()) { vr = generateOutcome(rootView, outcomeData.getName(), li); outcomeIndex.put(outcomeData.getName(), vr); } } }
From source file:cz.muni.fi.japanesedictionary.fragments.DisplaySentenceInfo.java
/** * Updates Fragment view acording to saved japanese character. * *///from ww w . jav a2 s.c o m private void updateSentence(View view) { Log.i(LOG_TAG, "Setting sentence"); if (mTatoebaSentence == null) { Toast.makeText(getActivity(), R.string.character_unknown_sentence, Toast.LENGTH_LONG).show(); return; } if (view == null || getActivity() == null) { return; } updateLanguages(); if (mTatoebaSentence.getJapaneseSentence() != null) { TextView japanese = (TextView) view.findViewById(R.id.sentence_japanese); japanese.setText(mTatoebaSentence.getJapaneseSentence()); } boolean hasMeaning = false; ViewGroup container = (ViewGroup) view.findViewById(R.id.tatoeba_sentences_lines_container); if ((mEnglish || (!mDutch && !mFrench && !mGerman && !mRussian)) && mTatoebaSentence.getEnglish() != null) { Log.i(LOG_TAG, "Setting english meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.sentence_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.sentence_language); if (!mFrench && !mDutch && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_english); TextView meaningTextView = (TextView) languageView.findViewById(R.id.sentence_translation); meaningTextView.setText(mTatoebaSentence.getEnglish()); container.addView(languageView); } if (mFrench && mTatoebaSentence.getFrench() != null) { Log.i(LOG_TAG, "Setting french meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.sentence_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.sentence_language); if (!mEnglish && !mDutch && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_french); TextView meaningTextView = (TextView) languageView.findViewById(R.id.sentence_translation); meaningTextView.setText(mTatoebaSentence.getFrench()); container.addView(languageView); } if (mDutch && mTatoebaSentence.getDutch() != null) { Log.i("DisplayCharacter", "Setting dutch meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.sentence_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.sentence_language); if (!mFrench && !mEnglish && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_dutch); TextView meaningTextView = (TextView) languageView.findViewById(R.id.sentence_translation); meaningTextView.setText(mTatoebaSentence.getDutch()); container.addView(languageView); } if (mGerman && mTatoebaSentence.getGerman() != null) { Log.i(LOG_TAG, "Setting german meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.sentence_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.sentence_language); if (!mFrench && !mDutch && !mEnglish && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_german); TextView meaningTextView = (TextView) languageView.findViewById(R.id.sentence_translation); meaningTextView.setText(mTatoebaSentence.getGerman()); container.addView(languageView); } if (mRussian && mTatoebaSentence.getRussian() != null) { Log.i(LOG_TAG, "Setting russian meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.sentence_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.sentence_language); if (!mFrench && !mDutch && !mEnglish && !mGerman) { language.setVisibility(View.GONE); } language.setText(R.string.language_russian); TextView meaningTextView = (TextView) languageView.findViewById(R.id.sentence_translation); meaningTextView.setText(mTatoebaSentence.getRussian()); container.addView(languageView); } if (!hasMeaning) { Log.i(LOG_TAG, "Doesn't have meanings"); getView().findViewById(R.id.kanjidict_meanings_container).setVisibility(View.GONE); } }
From source file:dev.drsoran.moloko.fragments.TaskFragment.java
private void setParticipantsSection(ViewGroup view, Task task) { final ParticipantList participants = task.getParticipants(); if (participants != null && participants.getCount() > 0) { view.setVisibility(View.VISIBLE); for (final Participant participant : participants.getParticipants()) { final TextView textView = new TextView(getSherlockActivity()); UIUtils.makeLink(textView, participant.getFullname(), new ClickableSpan() { @Override/*ww w . ja va 2s . c om*/ public void onClick(View widget) { listener.onOpenContact(participant.getFullname(), participant.getUsername()); } }); view.addView(textView); } } else { view.setVisibility(View.GONE); } }
From source file:com.gigamole.neon.adapters.PlayerPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View view;//from w w w. j a v a2 s.co m switch (position) { case Constants.COVER_PAGE: default: view = new SlideImageView(this.context); view.setTag(Constants.COVER_PAGE_TAG); ((SlideImageView) view).setAxis(SlideImageView.Axis.VERTICAL); ((SlideImageView) view).setSource(R.drawable.stub); break; case Constants.BAR_PAGE: view = new BarVisualizerView(this.context); view.setTag(Constants.BAR_PAGE_TAG); break; case Constants.GD_PAGE: view = new GravityDefiedVisualizerView(this.context); view.setTag(Constants.GD_PAGE_TAG); break; case Constants.SEA_PAGE: view = new SeaBreathVisualizerView(this.context); view.setTag(Constants.SEA_PAGE_TAG); break; case Constants.PULSE_PAGE: view = new PulseVisualizerView(this.context); view.setTag(Constants.PULSE_PAGE_TAG); break; } container.addView(view); return view; }
From source file:com.berniesanders.fieldthebern.adapters.LearnPagerAdapter.java
@Override public Object instantiateItem(ViewGroup viewGroup, int position) { LayoutInflater inflater = LayoutInflater.from(context); ViewGroup layout = null;/*w ww .ja v a 2s .co m*/ switch (position) { case 0: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_1, viewGroup, false); break; case 1: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_2, viewGroup, false); break; case 2: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_3, viewGroup, false); break; case 3: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_4, viewGroup, false); break; case 4: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_5, viewGroup, false); break; case 5: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_6, viewGroup, false); break; case 6: layout = (ViewGroup) inflater.inflate(R.layout.learn_page_7, viewGroup, false); break; } viewGroup.addView(layout); return layout; }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
private ImageButton addCloseButtonToViewGroup(final ViewGroup parent) { final ImageButton closeButton = new ImageButton(getContext()); final FrameLayout.LayoutParams closeButtonParams = new FrameLayout.LayoutParams(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE);/* ww w . jav a 2s . c o m*/ closeButtonParams.gravity = Gravity.RIGHT; closeButton.setLayoutParams(closeButtonParams); closeButton.setBackgroundColor(Color.TRANSPARENT); closeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { close(); } }); parent.addView(closeButton); return closeButton; }