トラッキング コード

7/27/2014

How to handle to auto flip with ViewFlipper

ViewFlipper do not have a handler to auto flipping.
If do handing, we should get Animation Class via VewFlipper#getInAnimation().
We register to Listener.


The follow code is sample.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
    View view = inflater.inflate(R.layout.fragment_flashing_card, null);
    mVewFlipper = (ViewFlipper) view.findViewById(R.id.viewFlipper1);
 
    mVewFlipper.setAutoStart(true);
    mVewFlipper.setInAnimation(getActivity(), android.R.anim.slide_in_left);
    mVewFlipper.getInAnimation().setAnimationListener(this);
    mVewFlipper.setFlipInterval(2000);
 
    return view;
}
 
@Override
public void onAnimationEnd(Animation animation) {
}
 
@Override
public void onAnimationRepeat(Animation animation) {
}
 
@Override
public void onAnimationStart(Animation animation) {
}