I want to take this android code and convert it to monoDroid
Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in2);
fade2.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(QuizSplashActivity.this,
QuizMenuActivity.class));
QuizSplashActivity.this.finish();
}
});
I have this so far
Animation fade2 = AnimationUtils.LoadAnimation(this, Resource.Animation.Fade_in2);
fade2.SetAnimationListener(????);
I don't see new AnimationListener(). It seems ot want some interface or something.
Your source Java code is making use of anonymous inner classes:
C# doesn't support these (C# 3 anonymous types are in no way similar to Java anonymous inner classes), so you need to provide an explicit type and use that instead:
As seen above, to implement the interface we also inherit from Java.Lang.Object (this implements
Android.Runtime.IJavaObject
for us), and instead of implicitly referencingQuizSplashActivity.this
as is done in Java, we instead need to explicitly capture it as aself
field.This could be simplified by providing a helper base type (I imagine that in the Java code the
AnimationListener
is a helper type, as not all of the Animation.AnimationListener methods were provided, so doing the ~same thing in C# would work as well).