Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Omar Barodi](https://secure.gravatar.com/avatar/d30cd51b0624483647b8f08595d9a9b6?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Omar Barodi
Courses Plus Student 1,276 PointsButton Click Method not working Confusing
I am not sur what I am missing
public class MainActivity extends Activity {
protected TransitionManager mTransitionManager;
protected Scene mScene1;
protected Scene mScene2;
protected Scene mCurrentScene;
protected TransitionSet mForwardSet;
protected TransitionSet mBackwardSet;
// Some code omitted for brevity
public void onButtonClicked(View view) {
if (mCurrentScene == mScene1) {
mCurrentScene = mScene2;
}
else {
mCurrentScene = mScene1;
}
mTransitionManager.setTransition(mCurrentScene);
}
protected void setupTransitions() {
// These methods are setting up scenes and transitions sets like in the video
initScenes();
initSets();
// Start here!
mTransitionManager = new TransitionManager();
mTransitionManager.setTransition(mScene1,mScene2,mForwardSet);
mTransitionManager.setTransition(mScene2,mScene1,mBackwardSet);
mScene1.enter();
}
}
1 Answer
![ofir moalmi](https://secure.gravatar.com/avatar/c9ca7608b52bde4d34f60f2f633de50d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
ofir moalmi
2,161 Pointsare you trying to run the if loop if the button is clicked?
![Omar Barodi](https://secure.gravatar.com/avatar/d30cd51b0624483647b8f08595d9a9b6?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Omar Barodi
Courses Plus Student 1,276 PointsThe instruction don't specify. All it says is fix the if loop, so it can transition correctly
Omar Barodi
Courses Plus Student 1,276 PointsOmar Barodi
Courses Plus Student 1,276 Points*sure