List of usage examples for android.view ViewGroup addView
public void addView(View child)
Adds a child view.
From source file:com.tecnojin.timekiller.menuviews.TutorialAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View v = li.inflate(R.layout.tutorial_page_layout, null); Page p = t.getPageAt(position);/*from ww w . j av a 2 s. c o m*/ ImageView i = (ImageView) v.findViewById(R.id.tutorialImage); TextView title = (TextView) v.findViewById(R.id.tutorialTitle); TextView content = (TextView) v.findViewById(R.id.tutorialText); if (p.getImage() != 0) i.setImageResource(p.getImage()); if (p.getTitle() != 0) title.setText(p.getTitle()); else title.setVisibility(View.INVISIBLE); content.setText(p.getText()); container.addView(v); return v; }
From source file:com.lillicoder.demo.carouselview.DemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demo); CarouselView carousel = (CarouselView) findViewById(R.id.carousel); carousel.setAdapter(new CarouselView.Adapter<Pair<String, Integer>>(getCarouselItems()) { @Override/*from w w w . j a va 2s . c o m*/ public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public void onDestroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public Object onInstantiateItem(ViewGroup container, int position) { Pair<String, Integer> pair = getItem(position); final LayoutInflater inflater = LayoutInflater.from(container.getContext()); TextView view = (TextView) inflater.inflate(R.layout.view_carousel_item, container, false); view.setBackgroundResource(pair.second); view.setText(pair.first); container.addView(view); return view; } }); }
From source file:com.anysoftkeyboard.ui.tutorials.ChangeLogFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); LayoutInflater inflater = LayoutInflater.from(getActivity()); ViewGroup logContainer = (ViewGroup) view.findViewById(getLogItemsContainerId()); for (VersionChangeLogs.VersionChangeLog change : VersionChangeLogs.createChangeLog()) { View logHeader = inflater.inflate(R.layout.changelogentry_header, logContainer, false); TextView versionName = (TextView) logHeader.findViewById(R.id.changelog_version_title); versionName.setPaintFlags(versionName.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); setTitleText(versionName, change.versionName); logContainer.addView(logHeader); for (String changeEntry : change.changes) { TextView entryView = (TextView) inflater.inflate(R.layout.changelogentry_item, logContainer, false); entryView.setText(getString(R.string.change_log_bullet_point, changeEntry)); logContainer.addView(entryView); }// w w w .j av a 2 s . com //TODO: add milestone url if (mLogToShow == SHOW_LATEST_CHANGELOG) break;//in this case, one is enough. //adding a divider between version logContainer.addView(inflater.inflate(R.layout.transparent_divider, logContainer, false)); } }
From source file:com.pedrogomez.renderers.PagerRendererAdapter.java
@Override public View instantiateItem(ViewGroup container, int position) { T content = getItem(position);//from w ww . j a v a 2s .co m rendererBuilder.withContent(content); rendererBuilder.withParent(container); rendererBuilder.withLayoutInflater(LayoutInflater.from(container.getContext())); Renderer<T> renderer = rendererBuilder.build(); if (renderer == null) { throw new NullRendererBuiltException("RendererBuilder have to return a not null Renderer"); } updateRendererExtraValues(content, renderer, position); renderer.render(); renderer.getRootView().setTag(content); container.addView(renderer.getRootView()); return renderer.getRootView(); }
From source file:com.gcssloop.diycode.activity.ImageActivity.java
/** * ? View ? initDatas ?//from ww w. ja v a 2s . co m * * @param holder * @param root */ @Override protected void initViews(ViewHolder holder, View root) { setTitle(""); mCache = new DiskImageCache(this); if (mCurrentMode == MODE_ERROR) { //TODO return; } // TODO ?? // ViewPager viewPager = holder.get(R.id.view_pager); Logger.e("Size" + images.size()); final LayoutInflater inflater = getLayoutInflater(); viewPager.setAdapter(new PagerAdapter() { @Override public int getCount() { return images.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = (PhotoView) inflater.inflate(R.layout.item_image, container, false); photoView.enable(); String url = images.get(position); if (mCache.hasCache(url)) { String file = mCache.getDiskPath(url); Glide.with(ImageActivity.this).load(file).into(photoView); } else { Glide.with(ImageActivity.this).load(images.get(position)).into(photoView); } container.addView(photoView); Logger.e("Item"); return photoView; } @Override public void destroyItem(ViewGroup container, int position, Object object) { PhotoView photoView = (PhotoView) container.findViewById(R.id.photo_view); container.removeView(photoView); } }); viewPager.setCurrentItem(current_image_position); }
From source file:com.csipsimple.wizards.impl.OneWorld.java
private void updateAccountInfos(final SipProfile acc) { if (acc != null && acc.id != SipProfile.INVALID_ID) { setFirstViewVisibility(false);/*from w w w . j a v a 2s . co m*/ customWizard.setVisibility(View.VISIBLE); customWizard.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String url = "http://www.1worldsip.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); parent.startActivity(i); } }); accountBalanceHelper.launchRequest(acc); } else { if (firstView == null) { firstView = new AccountCreationFirstView(parent); ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent(); firstView.setOnAccountCreationFirstViewListener(this); globalContainer.addView(firstView); } setFirstViewVisibility(true); } }
From source file:com.sweetiepiggy.littlepro.SubmitQuizFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_submit_quiz, container, false); ((Button) view.findViewById(R.id.submit_button)).setOnClickListener(this); ViewGroup questionsLayout = (ViewGroup) view.findViewById(R.id.questions_layout); if (mSubmitQuizListener != null) { for (Pair<Question, String> questionAndAnswer : mSubmitQuizListener.getQuestionAndAnswers()) { Question question = questionAndAnswer.first; String answer = questionAndAnswer.second; TextView answerView = new TextView(getActivity()); answerView.setText(answer);/* w w w . ja va 2 s .c om*/ mAnswerViews.add(answerView); questionsLayout.addView(answerView); mQuestionIdAndAnswers.put(question.getId(), answer); } } if (mSubmitted) { view.findViewById(R.id.submit_button).setVisibility(View.GONE); } return view; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w ww . j ava 2 s. c om byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } LinearLayout inner = new LinearLayout(context); inner.setLayoutParams(CommonLayouts.FULL_WIDTH); inner.setOrientation(LinearLayout.HORIZONTAL); frame.addView(inner); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); BitmapFactory bf = new BitmapFactory(); imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length)); inner.addView(imageView); ImageView iconView = new ImageView(context); iconView.setImageResource(R.drawable.play); iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); inner.addView(iconView); }
From source file:at.wada811.android.library.demos.view.ViewPagerAdapter.java
@Override public View instantiateItem(ViewGroup container, int position) { View page = mInflater.inflate(R.layout.layout_page, container, false); TextView textView = (TextView) page.findViewById(R.id.text); int rgb = position * 255; int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = rgb & 0xFF; r = g * 5 % 256;/*from www.j a va 2 s . com*/ g = b * 15 % 256; b = r * 25 % 256; int argb = Color.argb(255, r, g, b); textView.setText(String.format("#%02X%02X%02X", r, g, b)); textView.setTextColor(r > 192 || g > 192 || b > 192 ? Color.BLACK : Color.WHITE); page.setBackgroundColor(argb); container.addView(page); return page; }
From source file:com.limitfan.gojuuon.utils.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(com.limitfan.gojuuon.R.layout.detail_slide_page, container, false);// ww w. j ava 2 s . c o m ImageView stroke = (ImageView) (rootView.findViewById(com.limitfan.gojuuon.R.id.stroke)); String romaji = Common.roma[getPageNumber()]; try { String img = ""; if (ActKana.isHira) img = "kanagraph/hiragana_" + romaji + ".jpg"; else img = "kanagraph/katakana_" + romaji + ".jpg"; InputStream is = getContext().getAssets().open(img, AssetManager.ACCESS_STREAMING); Bitmap bm = BitmapFactory.decodeStream(is); stroke.setImageBitmap(bm); } catch (Exception e) { } ViewGroup listView = (ViewGroup) rootView.findViewById(com.limitfan.gojuuon.R.id.list); ViewGroup demo_speak = (ViewGroup) inflater.inflate(com.limitfan.gojuuon.R.layout.demo_list_item, null); ((TextView) demo_speak.findViewById(com.limitfan.gojuuon.R.id.text)) .setText(com.limitfan.gojuuon.R.string.demo); ((ImageView) demo_speak.findViewById(com.limitfan.gojuuon.R.id.icon)) .setImageResource(com.limitfan.gojuuon.R.drawable.speak_off); listView.addView(demo_speak); TextView sample = (TextView) (rootView.findViewById(com.limitfan.gojuuon.R.id.sample)); setSample(sample); demo_speak.setOnClickListener(new SpeakListener()); //stroke.setImageResource(); // Set the title view to show the page number. //EditText main = ((EditText) rootView.findViewById(R.id.Description)); // main.setText(getString(R.string.title_template_step, mPageNumber + 1)); //main.setEnabled(false); // main.setBackgroundColor(Color.TRANSPARENT); // main.setText(getFromAssets("details/"+(mPageNumber+1)+".txt")); return rootView; }