I have an OnClickListener on an image in my app. It allows the user to skip to a different part of the app if desired. The way the app runs, they can only use it 3 times.
My issue is, I want to get fancy pants. So I added an R.anim.fade_out animation to make the image fade out after all 3 times were used. I am using a counter decreased by one in another method.
The issue is, when the original method is recalled, it throws a Null Reference Exception because it can't find the image to set the OnClickListener. I tried wrapping it in an If/Else If statement:
if(skipsAllowed > 0){
skipButton.setOnClickListener(new OnClickListener(){
public void onClick(View v){
if(skipsAllowed > 0){
try {
skippedPage();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
}else if(skipsAllowed == 0){
skipFadeOut = AnimationUtils.loadAnimation(null, android.R.anim.fade_out);
skipButton.startAnimation(skipFadeOut);
}
This still didn't work. Any ideas on how to stop this?
I instantiate the ImageView at the start of every new call to this Activity, should I be placing that inside my If/Else If?