Methods Summary |
---|
public void | addView(android.view.View child, int index, ViewGroup.LayoutParams params)
super.addView(child, index, params);
if (getChildCount() == 1) {
child.setVisibility(View.VISIBLE);
} else {
child.setVisibility(View.GONE);
}
|
public int | getBaseline()
return (getCurrentView() != null) ? getCurrentView().getBaseline() : super.getBaseline();
|
public android.view.View | getCurrentView()Returns the View corresponding to the currently displayed child.
return getChildAt(mWhichChild);
|
public int | getDisplayedChild()Returns the index of the currently displayed child view.
return mWhichChild;
|
public android.view.animation.Animation | getInAnimation()Returns the current animation used to animate a View that enters the screen.
return mInAnimation;
|
public android.view.animation.Animation | getOutAnimation()Returns the current animation used to animate a View that exits the screen.
return mOutAnimation;
|
private void | initViewAnimator()
mMeasureAllChildren = true;
|
public void | removeAllViews()
super.removeAllViews();
mWhichChild = 0;
mFirstTime = true;
|
public void | removeView(android.view.View view)
final int index = indexOfChild(view);
if (index >= 0) {
removeViewAt(index);
}
|
public void | removeViewAt(int index)
super.removeViewAt(index);
final int childCount = getChildCount();
if (childCount == 0) {
mWhichChild = 0;
mFirstTime = true;
} else if (mWhichChild >= childCount) {
// Displayed is above child count, so float down to top of stack
setDisplayedChild(childCount - 1);
} else if (mWhichChild == index) {
// Displayed was removed, so show the new child living in its place
setDisplayedChild(mWhichChild);
}
|
public void | removeViewInLayout(android.view.View view)
removeView(view);
|
public void | removeViews(int start, int count)
super.removeViews(start, count);
if (getChildCount() == 0) {
mWhichChild = 0;
mFirstTime = true;
} else if (mWhichChild >= start && mWhichChild < start + count) {
// Try showing new displayed child, wrapping if needed
setDisplayedChild(mWhichChild);
}
|
public void | removeViewsInLayout(int start, int count)
removeViews(start, count);
|
public void | setAnimateFirstView(boolean animate)Indicates whether the current View should be animated the first time
the ViewAnimation is displayed.
mAnimateFirstTime = animate;
|
public void | setDisplayedChild(int whichChild)Sets which child view will be displayed.
mWhichChild = whichChild;
if (whichChild >= getChildCount()) {
mWhichChild = 0;
} else if (whichChild < 0) {
mWhichChild = getChildCount() - 1;
}
boolean hasFocus = getFocusedChild() != null;
// This will clear old focus if we had it
showOnly(mWhichChild);
if (hasFocus) {
// Try to retake focus if we had it
requestFocus(FOCUS_FORWARD);
}
|
public void | setInAnimation(android.view.animation.Animation inAnimation)Specifies the animation used to animate a View that enters the screen.
mInAnimation = inAnimation;
|
public void | setInAnimation(android.content.Context context, int resourceID)Specifies the animation used to animate a View that enters the screen.
setInAnimation(AnimationUtils.loadAnimation(context, resourceID));
|
public void | setOutAnimation(android.view.animation.Animation outAnimation)Specifies the animation used to animate a View that exit the screen.
mOutAnimation = outAnimation;
|
public void | setOutAnimation(android.content.Context context, int resourceID)Specifies the animation used to animate a View that exit the screen.
setOutAnimation(AnimationUtils.loadAnimation(context, resourceID));
|
public void | showNext()Manually shows the next child.
setDisplayedChild(mWhichChild + 1);
|
void | showOnly(int childIndex)Shows only the specified child. The other displays Views exit the screen
with the {@link #getOutAnimation() out animation} and the specified child
enters the screen with the {@link #getInAnimation() in animation}.
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (i == childIndex) {
if ((!mFirstTime || mAnimateFirstTime) && mInAnimation != null) {
child.startAnimation(mInAnimation);
}
child.setVisibility(View.VISIBLE);
mFirstTime = false;
} else {
if (mOutAnimation != null && child.getVisibility() == View.VISIBLE) {
child.startAnimation(mOutAnimation);
} else if (child.getAnimation() == mInAnimation)
child.clearAnimation();
child.setVisibility(View.GONE);
}
}
|
public void | showPrevious()Manually shows the previous child.
setDisplayedChild(mWhichChild - 1);
|