Beispiel #1
0
		/// <summary>Attaches a view to this view group.</summary>
		/// <remarks>
		/// Attaches a view to this view group. Attaching a view assigns this group as the parent,
		/// sets the layout parameters and puts the view in the list of children so it can be retrieved
		/// by calling
		/// <see cref="getChildAt(int)">getChildAt(int)</see>
		/// .
		/// This method should be called only for view which were detached from their parent.
		/// </remarks>
		/// <param name="child">the child to attach</param>
		/// <param name="index">the index at which the child should be attached</param>
		/// <param name="params">the layout parameters of the child</param>
		/// <seealso cref="removeDetachedView(View, bool)">removeDetachedView(View, bool)</seealso>
		/// <seealso cref="detachAllViewsFromParent()">detachAllViewsFromParent()</seealso>
		/// <seealso cref="detachViewFromParent(View)">detachViewFromParent(View)</seealso>
		/// <seealso cref="detachViewFromParent(int)">detachViewFromParent(int)</seealso>
		protected internal virtual void attachViewToParent(android.view.View child, int index
			, android.view.ViewGroup.LayoutParams @params)
		{
			child.mLayoutParams = @params;
			if (index < 0)
			{
				index = mChildrenCount;
			}
			addInArray(child, index);
			child.mParent = this;
			child.mPrivateFlags = (child.mPrivateFlags & ~DIRTY_MASK & ~DRAWING_CACHE_VALID) 
				| DRAWN | INVALIDATED;
			this.mPrivateFlags |= INVALIDATED;
			if (child.hasFocus())
			{
				requestChildFocus(child, child.findFocus());
			}
		}
Beispiel #2
0
		private void addViewInner(android.view.View child, int index, android.view.ViewGroup
			.LayoutParams @params, bool preventRequestLayout)
		{
			if (mTransition != null)
			{
				// Don't prevent other add transitions from completing, but cancel remove
				// transitions to let them complete the process before we add to the container
				mTransition.cancel(android.animation.LayoutTransition.DISAPPEARING);
			}
			if (child.getParent() != null)
			{
				throw new System.InvalidOperationException("The specified child already has a parent. "
					 + "You must call removeView() on the child's parent first.");
			}
			if (mTransition != null)
			{
				mTransition.addChild(this, child);
			}
			if (!checkLayoutParams(@params))
			{
				@params = generateLayoutParams(@params);
			}
			if (preventRequestLayout)
			{
				child.mLayoutParams = @params;
			}
			else
			{
				child.setLayoutParams(@params);
			}
			if (index < 0)
			{
				index = mChildrenCount;
			}
			addInArray(child, index);
			// tell our children
			if (preventRequestLayout)
			{
				child.assignParent(this);
			}
			else
			{
				child.mParent = this;
			}
			if (child.hasFocus())
			{
				requestChildFocus(child, child.findFocus());
			}
			android.view.View.AttachInfo ai = mAttachInfo;
			if (ai != null && (mGroupFlags & FLAG_PREVENT_DISPATCH_ATTACHED_TO_WINDOW) == 0)
			{
				bool lastKeepOn = ai.mKeepScreenOn;
				ai.mKeepScreenOn = false;
				child.dispatchAttachedToWindow(mAttachInfo, (mViewFlags & VISIBILITY_MASK));
				if (ai.mKeepScreenOn)
				{
					needGlobalAttributesUpdate(true);
				}
				ai.mKeepScreenOn = lastKeepOn;
			}
			onViewAdded(child);
			if ((child.mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE)
			{
				mGroupFlags |= FLAG_NOTIFY_CHILDREN_ON_DRAWABLE_STATE_CHANGE;
			}
		}