Methods Summary |
---|
protected void | dispatchDraw(android.graphics.Canvas canvas)
|
public void | draw(android.graphics.Canvas canvas)
|
public int | getInflatedId()Returns the id taken by the inflated view. If the inflated id is
{@link View#NO_ID}, the inflated view keeps its original id.
return mInflatedId;
|
public android.view.LayoutInflater | getLayoutInflater()Get current {@link LayoutInflater} used in {@link #inflate()}.
return mInflater;
|
public int | getLayoutResource()Returns the layout resource that will be used by {@link #setVisibility(int)} or
{@link #inflate()} to replace this StubbedView
in its parent by another view.
return mLayoutResource;
|
public android.view.View | inflate()Inflates the layout resource identified by {@link #getLayoutResource()}
and replaces this StubbedView in its parent by the inflated layout resource.
final ViewParent viewParent = getParent();
if (viewParent != null && viewParent instanceof ViewGroup) {
if (mLayoutResource != 0) {
final ViewGroup parent = (ViewGroup) viewParent;
final LayoutInflater factory;
if (mInflater != null) {
factory = mInflater;
} else {
factory = LayoutInflater.from(getContext());
}
final View view = factory.inflate(mLayoutResource, parent,
false);
if (mInflatedId != NO_ID) {
view.setId(mInflatedId);
}
final int index = parent.indexOfChild(this);
parent.removeViewInLayout(this);
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams != null) {
parent.addView(view, index, layoutParams);
} else {
parent.addView(view, index);
}
mInflatedViewRef = new WeakReference<View>(view);
if (mInflateListener != null) {
mInflateListener.onInflate(this, view);
}
return view;
} else {
throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
}
} else {
throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
}
|
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec)
setMeasuredDimension(0, 0);
|
public void | setInflatedId(int inflatedId)Defines the id taken by the inflated view. If the inflated id is
{@link View#NO_ID}, the inflated view keeps its original id.
mInflatedId = inflatedId;
|
public void | setLayoutInflater(android.view.LayoutInflater inflater)Set {@link LayoutInflater} to use in {@link #inflate()}, or {@code null}
to use the default.
mInflater = inflater;
|
public void | setLayoutResource(int layoutResource)Specifies the layout resource to inflate when this StubbedView becomes visible or invisible
or when {@link #inflate()} is invoked. The View created by inflating the layout resource is
used to replace this StubbedView in its parent.
mLayoutResource = layoutResource;
|
public void | setOnInflateListener(android.support.v7.internal.widget.ViewStubCompat$OnInflateListener inflateListener)Specifies the inflate listener to be notified after this ViewStub successfully
inflated its layout resource.
mInflateListener = inflateListener;
|
public void | setVisibility(int visibility)When visibility is set to {@link #VISIBLE} or {@link #INVISIBLE},
{@link #inflate()} is invoked and this StubbedView is replaced in its parent
by the inflated layout resource. After that calls to this function are passed
through to the inflated view.
if (mInflatedViewRef != null) {
View view = mInflatedViewRef.get();
if (view != null) {
view.setVisibility(visibility);
} else {
throw new IllegalStateException("setVisibility called on un-referenced view");
}
} else {
super.setVisibility(visibility);
if (visibility == VISIBLE || visibility == INVISIBLE) {
inflate();
}
}
|