ViewFlipper without looping

  • Replies:0
Oliver Weissbarth
  • Forum posts: 1

Aug 7, 2013, 12:05:54 PM via Website

Hey guys. I got a problem with a ViewFlipper. I want to do something similar to a slideshow. But i want to go through all views and stop when it reaches the last one. I found a solution for this here on Stackoverflow . My problem is now that this.flipper.getAnimation() returns a Nullpointer. I hope you can help me. Here is my relevant code:
1public class RunningTake extends Activity implements AnimationListener {
2
3 private ViewFlipper flipper;
4
5@Override
6protected void onCreate(Bundle savedInstanceState) {
7 super.onCreate(savedInstanceState);
8 setContentView(R.layout.activity_take_infoswitcher);
9 this.flipper = ((ViewFlipper)findViewById(R.id.takeviewflipper));
10 }
11
12public void onButtonClick(View view){
13 setValues();
14 int interval =2000;
15 this.flipper.setFlipInterval(interval);
16 this.flipper.startFlipping();
17 this.flipper.getAnimation().setAnimationListener(this);
18 }
19
20
21private void setValues(){
22 //some other code
23}
24
25
26@Override
27public void onAnimationEnd(Animation arg0) {
28 if(this.flipper.getDisplayedChild()==this.flipper.getChildCount()-1){
29 this.flipper.stopFlipping();
30 }
31
32}
33
34@Override
35public void onAnimationRepeat(Animation arg0) {
36 // TODO Auto-generated method stub
37
38}
39
40@Override
41public void onAnimationStart(Animation arg0) {
42 // TODO Auto-generated method stub
43
44}
45}
Thanks you in advance for your help.

Reply