So right now i am having trouble making the next button unclickable when it is on the last page of the activity. As of right now it goes back to the first screen. How do i make it so that it know when to grey out the button or make it unclickable when the user gets to the last screen.
Here is my code:
public class ReadingActivity extends Activity implements OnClickListener {
private ViewFlipper viewFlipper;
Button btnNext, btnPrev;
private float lastX;
/** Called when the activity is first created */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reading);
viewFlipper=(ViewFlipper)findViewById(R.id.view_flipper);
btnNext=(Button)findViewById(R.id.btnNext);
btnPrev=(Button)findViewById(R.id.btnPre);
btnNext.setOnClickListener(this);
btnPrev.setOnClickListener(this);
btnNext.setEnabled(true);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId()){
case R.id.btnNext:
viewFlipper.setInAnimation(this, R.anim.in_from_right);
viewFlipper.setOutAnimation(this, R.anim.out_to_left);
viewFlipper.showNext();
break;
case R.id.btnPre:
viewFlipper.setInAnimation(this, R.anim.in_from_left);
viewFlipper.setOutAnimation(this, R.anim.out_to_right);
viewFlipper.showPrevious();
break;
}
}
}
you can set the OnClickListener to null like so
btnNext.setOnClickListener(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With