ViewFlipper without looping

Put your problem here if it does not fit any of the other categories.

ViewFlipper without looping

Postby oweissbarth » Wed Aug 07, 2013 10:51 am

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: http://stackoverflow.com/questions/1261 ... om-looping (Answer 3). My problem is now that this.flipper.getAnimation() returns a Nullpointer. I hope you can help me. Here is my relevant code:
Code: Select all
public class RunningTake extends Activity implements AnimationListener {
       
        ViewFlipper flipper;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_take_infoswitcher);
                this.flipper = ((ViewFlipper)findViewById(R.id.takeviewflipper));
        }
       
public void onButtonClick(View view){
        setValues();
        int interval =2000;
        this.flipper.setFlipInterval(interval);
        this.flipper.startFlipping();
        this.flipper.getAnimation().setAnimationListener(this);
        }
       

private void setValues(){
        //some other code
}
       

@Override
public void onAnimationEnd(Animation arg0) {
        if(this.flipper.getDisplayedChild()==this.flipper.getChildCount()-1){
                this.flipper.stopFlipping();
        }
               
}

@Override
public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub
               
}

@Override
public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub
               
}


Thanks in advance.
oweissbarth
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Aug 07, 2013 10:38 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests