Android Activity – Navigating From One Screen To Another Screen

android navigate

In Android, what you see is activity. You interact with Android application through activity. Usually application has more than one activity that are connected each other. In other words, what you see in an Android device is an activity

Refering to Android Developer Site (http://developer.android.com/guide/components/activities.html)
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.

In this tutorial we will show you how to play with activity. We will create 2 activity in which it navigates to each other when a button is clicked.

1. Create Project

We assume you understand creating Android project using eclipse, including create an AVD (Android Virtual Device) and running it. If you never know before you can learn it here

2. Create Layout

Create two xml layout files in “res/layout”
1. activity_first.xml –> Represents Screen 1
2. activity_second.xml –> Represents Screen 2

file : activity_first.xml

file : activity_second.xml

2. Create Activity

Create two activity classes. Each activity has one layout we have created before
1. FirstActivity.java –> activity_first.xml
2. SecondActivity.java –> activity_second.xml

file : FirstActivity.java

file : SecondActivity.java

3. Android Manifest

Declare two activity above in AndroidManifest.xml

file : AndroidManifest.xml

Running Application

shot_000008

shot_000011

Facebook Comments
 

Agung Setiawan

Agung Setiawan adalah software engineer di BukaLapak.com, penulis sekaligus pecinta sastra, dan pembaca buku

 
Halo, perkenalkan saya Agung Setiawan.
Saya Software Engineer di BukaLapak.
Simak pemikian saya soal dunia Software Engineering via Twitter di @agungsetiawanmu dan facebook
Blog ini saya update seminggu sekali jadi sering-sering saja mampir
Mau belajar Vim bareng saya?
Belajar ngoding dari nol menggunakan PHP

One thought on “Android Activity – Navigating From One Screen To Another Screen

  1. gan, itu kalo pake button
    kalo di swipe gmana ya ?

    trus itu berarti masuk ke xml babru ?
    dalam 1 xml, bisa dinavigate ke 3 cml / lebih ga ?

    jadi misal xml 1. isinya ada 3 button yg ngarah ke xml lain. bsa kan ?

Leave a Reply

Your email address will not be published. Required fields are marked *