本文整理匯總了Java中android.widget.ViewAnimator.getDisplayedChild方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewAnimator.getDisplayedChild方法的具體用法?Java ViewAnimator.getDisplayedChild怎麽用?Java ViewAnimator.getDisplayedChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ViewAnimator
的用法示例。
在下文中一共展示了ViewAnimator.getDisplayedChild方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: flipTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will
* initiate a {@link FlipAnimation} to show the next View.
* If the currently visible view is the last view, flip direction will be reversed for this
* transition.
*
* @param viewAnimator the {@code ViewAnimator}
* @param dir the direction of flip
* @param duration the transition duration in milliseconds
*/
public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir,
long duration) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
Animation[] animc = AnimationFactory.flipAnimation(fromView, toView,
(nextIndex < currentIndex ? dir.theOtherDirection() : dir), duration, null);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}
示例2: flipTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Flip to the next view of the {@code ViewAnimator}'s subviews. A call
* to this method will initiate a {@link FlipAnimation} to show the next
* View. If the currently visible view is the last view, flip direction
* will be reversed for this transition.
*
* @param viewAnimator the {@code ViewAnimator}
* @param dir the direction of flip
* @param duration the transition duration in milliseconds
*/
public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir, long duration) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1)%viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
if(android.os.Build.VERSION.SDK_INT>=12) {
//New way of flipping.
flipTransition(fromView, toView);
}else{
//Traditional flip.
Animation[] animc = AnimationFactory.flipAnimation(fromView, toView,
(nextIndex < currentIndex?dir.theOtherDirection():dir), duration, null);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}
}
示例3: setDisplayedChild
import android.widget.ViewAnimator; //導入方法依賴的package包/類
@BindingAdapter("displayedChild")
public static void setDisplayedChild(@NonNull final ViewAnimator viewAnimator,
final int child) {
if (viewAnimator.getDisplayedChild() != child) {
viewAnimator.setDisplayedChild(child);
}
}
示例4: show
import android.widget.ViewAnimator; //導入方法依賴的package包/類
@UiThread
public void show(@IdRes int viewId) {
ViewAnimator animator = (ViewAnimator) sceneView.findViewById(animatorId);
View view = sceneView.findViewById(viewId);
if (animator.getDisplayedChild() != animator.indexOfChild(view)) {
animator.setDisplayedChild(animator.indexOfChild(view));
}
}
示例5: tryFlipToPreviousView
import android.widget.ViewAnimator; //導入方法依賴的package包/類
public static boolean tryFlipToPreviousView(final ViewAnimator viewAnimator) {
if (viewAnimator == null || viewAnimator.getDisplayedChild() == 0) return false;
viewAnimator.showPrevious();
return true;
}
示例6: onViewChanged
import android.widget.ViewAnimator; //導入方法依賴的package包/類
@Override
public void onViewChanged(ViewAnimator viewAnimator) {
if (viewAnimator.getDisplayedChild() > 0) {
if (numberOfMenusShown == 0 && onAnyMenuShown != null) onAnyMenuShown.onAnyMenuShown();
++numberOfMenusShown;
if (shownMenu != null)
LongClickViewAnimatorListener.tryFlipToPreviousView(shownMenu);
shownMenu = viewAnimator;
} else {
if (shownMenu == viewAnimator) shownMenu = null;
if (--numberOfMenusShown == 0 && onAllMenusHidden != null) onAllMenusHidden.onAllMenusHidden();
}
if (onViewChangedListener != null)
onViewChangedListener.onViewChanged(viewAnimator);
}
示例7: flipTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View.
* If the currently visible view is the last view, flip direction will be reversed for this transition.
*
* @param viewAnimator the {@code ViewAnimator}
* @param dir the direction of flip
*/
public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1)%viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, (nextIndex < currentIndex?dir.theOtherDirection():dir), 500, null);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}
示例8: flipTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View.
* If the currently visible view is the last view, flip direction will be reversed for this transition.
*
* @param viewAnimator the {@code ViewAnimator}
* @param dir the direction of flip
* @param duration the transition duration in milliseconds
*/
public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir, long duration) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1)%viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, (nextIndex < currentIndex?dir.theOtherDirection():dir), duration, null);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}
示例9: flipTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View.
* If the currently visible view is the last view, flip direction will be reversed for this transition.
*
* @param viewAnimator the {@code ViewAnimator}
* @param dir the direction of flip
*/
public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, (nextIndex < currentIndex ? dir.theOtherDirection() : dir), 500, null);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}
示例10: fadeTransition
import android.widget.ViewAnimator; //導入方法依賴的package包/類
/**
* Fades out the current view to the next view of the {@code ViewAnimator}'s subviews with a fade in
* effect. If the currently visible view is the last view, fade will restore the front view.
*
* @param viewAnimator
* @param fadeOutDuration
* @param fadeInDuration
*/
public static void fadeTransition(final ViewAnimator viewAnimator, long fadeOutDuration, long fadeInDuration) {
final View fromView = viewAnimator.getCurrentView();
final int currentIndex = viewAnimator.getDisplayedChild();
final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();
final View toView = viewAnimator.getChildAt(nextIndex);
Animation[] animc = fadeTransition(fromView, toView, fadeOutDuration, fadeInDuration);
viewAnimator.setOutAnimation(animc[0]);
viewAnimator.setInAnimation(animc[1]);
viewAnimator.showNext();
}