Android Development Tutorial #4 – Switching Between Activities – Example

We Already Seen Some Of The Basic Android Development Tutorial On Tech4bros , In This Android Development Tutorial #4 We Will See How to Switch Between Two Activities Using Button .

What is An Activity ?

An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI setContentView(View) . 

Source :


Initial Setup :

For Initial Setup of SDK and AVD follow this tutorial – Android Development Tutorial #1 : Setting Up ADT & Developing Hello World App.

File Tree :

file tree tutorial 4

Project :

  • Create new project in eclipse by selecting File -> New -> Android Application Project. Give a Application name, Project name and Package name.

switch betwwn activities


  • Create 2 Layouts Named “Layout 1.xml“,”Layout 2.xml” By Doing Right Click on Layout Folder Under res/layout Using New > Android XML File





  • Create 2 Activity Files Under Source Folder Named ““,”” By Doing Right Click on src Folder New >  Class 

creating new java class


  • We Are Using OnClickListener() Function in Activity File i.e , When A Button of ID = xxx Clicked What it have to do ? It Have to Open the Second layout And For the Activity2 Vice Versa .

 Android Manifest.xml

The Above Code Should be Added In Order to Declare the Created Activity

declaring activity in AndroidManifest.xml



Download Full Project :


Download From Google Drive