Android Switching Between Activities – Example


You may also like...

  • Hbissle

    I’ve tried the tut but it references Activity1.class / Activity2.class in your java files and my code has an error because I don’t have them in this project can you please advise where to get them. Or how (and in what folder) to create them?

    Thank you.


    • Raj Amal

      You must create the JAVA classes in “src” folder.

  • A Toggler WannaBe

    The above code doesn’t “switch between activities”. It just creates instance after instance of the activities. I’m trying to switch between activities.

  • carterson2

    Raj, Maybe if you included a zip file, people could try easier. Thanks for posting!

  • Francis Lambeets

    The code works fine, even using an EditText field instead of a button. However, Toggler WannaBe is right when he says the code doesn’t really switch, it indeed creates instances of both activities one upon the other. Is there a way to close the previous activity after each switch?