List of usage examples for android.view ViewGroup addView
public void addView(View child)
Adds a child view.
From source file:edu.stanford.mobisocial.dungbeetle.ui.ViewContactActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_feed_home); checked = new boolean[filterTypes.length]; for (int x = 0; x < filterTypes.length; x++) { checked[x] = true;//from ww w . j av a2 s . c om } findViewById(R.id.btn_broadcast).setVisibility(View.GONE); mContactId = getIntent().getLongExtra("contact_id", -1); if (mContactId == -1) { Uri data = getIntent().getData(); if (data != null) { try { mContactId = Long.parseLong(data.getLastPathSegment()); } catch (NumberFormatException e) { } } } Bundle args = new Bundle(); args.putLong("contact_id", mContactId); Fragment profileFragment = new ViewProfileFragment(); profileFragment.setArguments(args); if (mContactId == Contact.MY_ID) { doTitleBar(this, "My Profile"); mLabels.add("View"); mLabels.add("Edit"); mFragments.add(profileFragment); mFragments.add(new EditProfileFragment()); // TODO: Legitimize this. Move objects to a randomly generated private feed // Ability to "move" private feeds. // Have a "feedPtrObj" that tracks your current private. Store in-app feed. Uri privateUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/private"); mLabels.add("Notes"); Fragment feedView = new FeedViewFragment(); args = new Bundle(args); args.putParcelable(FeedViewFragment.ARG_FEED_URI, privateUri); feedView.setArguments(args); mFragments.add(feedView); } else { String title = "Profile"; Uri feedUri = null; try { Contact contact = Contact.forId(this, mContactId).get(); title = contact.name; feedUri = contact.getFeedUri(); } catch (NoValError e) { } args.putParcelable(FeedViewFragment.ARG_FEED_URI, feedUri); doTitleBar(this, title); mLabels.add("Feed"); mLabels.add("Apps"); mLabels.add("Profile"); Fragment feedView = new FeedViewFragment(); feedView.setArguments(args); Fragment appView = new AppsViewFragment(); appView.setArguments(args); mFragments.add(feedView); mFragments.add(appView); mFragments.add(profileFragment); if (MusubiBaseActivity.getInstance().isDeveloperModeEnabled()) { FeedView sharingView = new PresenceView(); sharingView.getFragment().setArguments(args); mLabels.add(sharingView.getName()); mFragments.add(sharingView.getFragment()); } } PagerAdapter adapter = new ViewFragmentAdapter(getSupportFragmentManager(), mFragments); mViewPager = (ViewPager) findViewById(R.id.feed_pager); mViewPager.setAdapter(adapter); mViewPager.setOnPageChangeListener(this); ViewGroup group = (ViewGroup) findViewById(R.id.tab_frame); int i = 0; for (String s : mLabels) { Button button = new Button(this); button.setText(s); button.setTextSize(18f); button.setLayoutParams(CommonLayouts.FULL_HEIGHT); button.setTag(i++); button.setOnClickListener(mViewSelected); group.addView(button); mButtons.add(button); } // Listen for future changes Uri feedUri; if (mContactId == Contact.MY_ID) { feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/me"); } else { feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"); } mProfileContentObserver = new ProfileContentObserver(mHandler); getContentResolver().registerContentObserver(feedUri, true, mProfileContentObserver); onPageSelected(0); }
From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java
private void initializeViews(View container) { mLogoView.setVisibility(View.GONE); // Create custom views. LayoutInflater inflater = getThemeInflater(LayoutInflater.from(getActivity())); ViewGroup backgroundContainer = (ViewGroup) container.findViewById(R.id.background_container); View background = onCreateBackgroundView(inflater, backgroundContainer); if (background != null) { backgroundContainer.setVisibility(View.VISIBLE); backgroundContainer.addView(background); }//from ww w . jav a2s. c o m ViewGroup contentContainer = (ViewGroup) container.findViewById(R.id.content_container); View content = onCreateContentView(inflater, contentContainer); if (content != null) { contentContainer.setVisibility(View.VISIBLE); contentContainer.addView(content); } ViewGroup foregroundContainer = (ViewGroup) container.findViewById(R.id.foreground_container); View foreground = onCreateForegroundView(inflater, foregroundContainer); if (foreground != null) { foregroundContainer.setVisibility(View.VISIBLE); foregroundContainer.addView(foreground); } // Make views visible which were invisible while logo animation is running. container.findViewById(R.id.page_container).setVisibility(View.VISIBLE); container.findViewById(R.id.content_container).setVisibility(View.VISIBLE); if (getPageCount() > 1) { mPageIndicator.setPageCount(getPageCount()); mPageIndicator.onPageSelected(mCurrentPageIndex, false); } if (mCurrentPageIndex == getPageCount() - 1) { mStartButton.setVisibility(View.VISIBLE); } else { mPageIndicator.setVisibility(View.VISIBLE); } // Header views. mTitleView.setText(getPageTitle(mCurrentPageIndex)); mDescriptionView.setText(getPageDescription(mCurrentPageIndex)); }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private void init(Context context) { this.mContext = context; // this mContainerView will be added when animation happened, // see DestroySelfSpringListener.onSpringActivate() mContainerView = new FrameLayout(context); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.c_text_view, mContainerView, false); mContainerView.addView(view);/*ww w . j av a2 s . c o m*/ mContainerView.addView(mRevealCircle = generateRevealCircle()); //generate and add follow circles if (mEnableFollowAnimation) { mFollowCircles = generateFollowCircles(); for (int i = mFollowCircles.size() - 1; i >= 0; i--) { // note follow circles is not added in container view, is just added in this SpringFloatingActionMenu addView(mFollowCircles.get(i)); } } //generate and add menuItemViews mMenuItemViews = generateMenuItemViews(); for (MenuItemView menuItemView : mMenuItemViews) { mContainerView.addView(menuItemView); addOnMenuActionListener(menuItemView); } mMenuItemViews.get(0).bringToFront(); // addView(mContainerView); //add FAB LayoutParams fablp = Utils.createWrapParams(); fablp.gravity = mGravity; addView(mFAB, fablp); setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); //add self to root view ViewGroup rootView = (ViewGroup) ((Activity) mContext).findViewById(android.R.id.content); rootView.addView(this); bringToFront(); getViewTreeObserver().addOnGlobalLayoutListener(this); mFAB.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mAnimating) { return; } if (disableOpenMenuCapability) { return; } if (mOnFabClickListener != null) { mOnFabClickListener.onClcik(); } if (mMenuOpen) { hideMenu(); } else { showMenu(); } } }); }
From source file:cm.aptoidetv.pt.ViewPagerAdapterScreenshots.java
@Override public Object instantiateItem(ViewGroup container, final int position) { final View v = LayoutInflater.from(context).inflate(R.layout.row_item_screenshots_big, null); final ProgressBar pb = (ProgressBar) v.findViewById(R.id.screenshots_loading_big); String icon;//from w w w.j a v a2s .c o m if (hd) { Log.d("Aptoide-Screenshots", "Icon is hd: " + url.get(position)); if (url.get(position).contains("_screen")) { icon = url.get(position).split("\\|")[1]; Log.d("Aptoide-Screenshots", "Icon is : " + icon); } else { icon = url.get(position); } } else { icon = screenshotToThumb(url.get(position)); } Picasso.with(context).load(icon).error(R.drawable.icon_non_available) .into((ImageView) v.findViewById(R.id.screenshot_image_big)); container.addView(v); if (!hd) { v.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(context, ScreenshotsViewer.class); i.putStringArrayListExtra("url", url); i.putExtra("position", position); context.startActivity(i); } }); } return v; }
From source file:com.waz.zclient.pages.main.participants.views.TabbedParticipantPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View v;/* w ww .j a v a 2 s . co m*/ switch (ParticipantTabs.values()[position]) { case DETAILS: v = new ParticipantDetailsTab(context); v.setTag(ParticipantTabs.DETAILS); break; case DEVICES: RecyclerView rv = new RecyclerView(context); rv.setLayoutManager(new LinearLayoutManager(context)); rv.setHasFixedSize(true); rv.setAdapter(participantOtrDeviceAdapter); rv.setRecyclerListener(this); ViewUtils.setPaddingBottom(rv, context.getResources().getDimensionPixelSize(R.dimen.participants__otr_device__padding_bottom)); rv.setClipToPadding(false); v = rv; break; default: throw new RuntimeException("Unexpected ViewPager position"); } container.addView(v); return v; }
From source file:com.tapchatapp.android.app.ui.TapchatFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { int newPos = getItemPosition(f); if (position == newPos) { if (f.getView() != null && f.getView().getParent() != container) { ((ViewGroup) f.getView().getParent()).removeView(f.getView()); container.addView(f.getView()); }/*from w ww . j a v a 2s. co m*/ return f; } else { mFragments.remove(position); mFragments.ensureCapacity(newPos + 1); for (int i = mFragments.size(); i < (newPos + 1); i++) { mFragments.add(null); } mFragments.set(newPos, f); } } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, getTag(position)); return fragment; }
From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesAdapter.java
@Override public Object instantiateItem(final ViewGroup container, final int position) { if (DEBUG_PAGER) { Log.d(TAG, "instantiate item: " + position); }// www . j a va 2s . co m final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position); if (oldKeyboardView != null) { oldKeyboardView.deallocateMemory(); // This may be redundant but wanted to be safer.. mActiveKeyboardViews.remove(position); } final Keyboard keyboard = mEmojiCategory.getKeyboardFromPagePosition(position); final LayoutInflater inflater = LayoutInflater.from(container.getContext()); final EmojiPageKeyboardView keyboardView = (EmojiPageKeyboardView) inflater .inflate(R.layout.emoji_keyboard_page, container, false /* attachToRoot */); keyboardView.setKeyboard(keyboard); keyboardView.setOnKeyEventListener(mListener); container.addView(keyboardView); mActiveKeyboardViews.put(position, keyboardView); return keyboardView; }
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override public void initPlayerView(int playerSlot, String name) { final ViewGroup teamBlock = (playerSlot < 5 ? (ViewGroup) findViewById(R.id.game_radiant_block) : (ViewGroup) findViewById(R.id.game_dire_block)); mPlayerLayouts[playerSlot] = getLayoutInflater().inflate(R.layout.player_live_detail, teamBlock, false); ((TextView) mPlayerLayouts[playerSlot].findViewById(R.id.player_name)).setText(name); teamBlock.addView(mPlayerLayouts[playerSlot]); }
From source file:com.github.michalbednarski.intentslab.uihelpers.FragmentTabMergingPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int page) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }/*from w w w . j ava2 s . com*/ // Get info about page final MultiFragmentPageInfo pageInfo = mPagesInfoMap[page]; final int fragmentsOnPage = pageInfo != null ? pageInfo.fillInIds.length : 1; final int firstFragmentOnPage = mPageToFirstFragmentMap[page]; // Prepare wrapper layout final View view; final Fragment[] addedFragments; if (pageInfo != null) { view = LayoutInflater.from(container.getContext()).inflate(pageInfo.containerLayout, container, false); container.addView(view); addedFragments = new Fragment[fragmentsOnPage]; } else { view = null; addedFragments = null; } // Prepare all fragments on page final int pagerId = container.getId(); for (int i = 0; i < fragmentsOnPage; i++) { final int fragmentIndex = firstFragmentOnPage + i; final int containerId = pageInfo == null ? pagerId : pageInfo.fillInIds[i]; // Do we already have this fragment? String name = makeFragmentName(pagerId, fragmentIndex); Fragment fragment = mFragmentManager.findFragmentByTag(name); if (fragment != null) { if (DEBUG) Log.v(TAG, "Attaching item #" + fragmentIndex + ": f=" + fragment); if (fragment.getId() != containerId) { // Added to another container moveFragment(fragment, containerId); } else { // Already added, possibly detached if (pageInfo != null) { // When activity was created this tab wasn't ready // Detach and re-attach this fragment mCurTransaction.detach(fragment); } mCurTransaction.attach(fragment); } } else { // Not added fragment = mFragments[fragmentIndex]; if (DEBUG) Log.v(TAG, "Adding item #" + fragmentIndex + ": f=" + fragment); mCurTransaction.add(containerId, fragment, name); } // Deactivate menu if not on current page if (page != mCurrentPrimaryPage) { fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); } // For single fragment page return fragment if (pageInfo == null) { return fragment; } // On multi fragment page add to page addedFragments[i] = fragment; } // Return descriptor of multi fragment page return new AddedPageInfo(view, addedFragments); }
From source file:com.pranavpandey.smallapp.permission.PermissionDangerous.java
private void buildPermissionsDialog(final ArrayList<String> permissions, final boolean isRequest) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.sas_dialog_permission, new LinearLayout(this), false); TextView message = (TextView) view.findViewById(R.id.permission_message); ViewGroup frame = (ViewGroup) view.findViewById(R.id.permission_frame); final ArrayList<String> permissionGroups = new ArrayList<String>(); for (String permission : permissions) { try {/*from w w w. j a v a 2s .co m*/ PermissionInfo permInfo = getPackageManager().getPermissionInfo(permission, PackageManager.GET_META_DATA); if (!permissionGroups.contains(permInfo.group)) { permissionGroups.add(permInfo.group); } } catch (NameNotFoundException e) { e.printStackTrace(); } } for (String permissionGroup : permissionGroups) { try { PermissionGroupInfo permGroupInfo = getPackageManager().getPermissionGroupInfo(permissionGroup, PackageManager.GET_META_DATA); frame.addView(new PermissionItem(this, permGroupInfo.loadIcon(getPackageManager()), permGroupInfo.loadLabel(getPackageManager()).toString(), permGroupInfo.loadDescription(getPackageManager()).toString())); } catch (NameNotFoundException e) { e.printStackTrace(); } } if (isRequest) { message.setText(R.string.sas_perm_request_desc); } else { message.setText(String.format(getString(R.string.sas_format_next_line), getString(R.string.sas_perm_request_desc), getString(R.string.sas_perm_request_info))); } try { alertDialogBuilder.setIcon( DynamicTheme.createDialogIcon(this, getPackageManager().getApplicationIcon(getPackageName()))); } catch (Exception e) { e.printStackTrace(); } alertDialogBuilder.setTitle(getApplicationInfo().loadLabel(getPackageManager()).toString()) .setPositiveButton(isRequest ? R.string.sas_perm_request : R.string.sas_perm_continue, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (isRequest) { requestPermissions(permissions.toArray(new String[permissions.size()])); } else { openPermissionSettings(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { finishPermissionsChecker(); } }).setCancelable(false); final AlertDialog dialog = alertDialogBuilder.create(); dialog.setView(view, 0, SmallUtils.getDialogTopPadding(this), 0, 0); showPermissionDialog(dialog); }