Android development basic _ZuoSyuanWang

Preview:

DESCRIPTION

Tutorial of Android Development. email: t1ina2003@gmail.com

Citation preview

Android Development Basic 1

Android Development BasicLecture1.1:Basic Setting

ZuoSyuan WangNational Sun Yat-sen University

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 2

Course Goal Environment Setting Up HelloWorld Application Four Heroes of android

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 3

Environment Setting Up

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 4

Environment Setting Up Java Development Kit (JDK) Android SDK + Eclipse ADT

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 5

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

2.

Android Development Basic 6

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

Android Development Basic 7

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

2.

Android Development Basic 8

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

Android Development Basic 9

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

Android Development Basic 10

Environment Setting Up JDK done!

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 11

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 12

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 13

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 14

Environment Setting Up Eclipse ADT plugin Android SDK Tools Android Platform-tools Android system image for the

emulator

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

ALL IN ONE!

Android Development Basic 15

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 16

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 17

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 18

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 19

Environment Setting Up InstallSDK

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 20

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 21

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 22

Environment Setting Up Detail of Package

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 23

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 24

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 25

Environment Setting Up Install 4.2.2 as tutorial example

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 26

Environment Setting Up IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

1.

2.

Android Development Basic 27

HelloWorld Application

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 28

HelloWorld Application File → New → Android Application

Project

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 29

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

App name (ex. Helloworld, myfirstproject, etc.)

Project name(ex. July_project, etc.)

Package name(ex. Com.nsysu.julypro, etc.)

Android Development Basic 30

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Choose Lowest API level

Choose Highest API level

Choose API level u want

Theme setting

Android Development Basic 31

HelloWorld Application

Just press“next”

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 32

HelloWorld Application

Just press“next”

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 33

HelloWorld Application

Just press“next”

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 34

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Main design Interface

Android Development Basic 35

HelloWorld Application

Why error?

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 36

HelloWorld Application

Right click project → Property → Java Build Path → Order and Export

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 37

HelloWorld Application

Right click project → Property → Java Build Path → Order and Export

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 38

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 39

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 40

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 41

HelloWorld Application IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 42

HelloWorld Application

Connect your Phone → the name of your phone show up

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 43

HelloWorld Application

Back to Java Perspective

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 44

HelloWorld Application

Right click your project → Run As → Andorid Application

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 45

HelloWorld Application

Choose a running Andorid device →Choose your device → press OK

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 46

HelloWorld Application

Done!

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 47

Four Heroes

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 48

Four Heroes Activity Intent Service Content Provider

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 49

Four Heroes - Activity Goal make switchable app via

intent

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Click it!

Click it!

Android Development Basic 50

Four Heroes - Activity One page one activity One layout one activity

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 51

Four Heroes - Activity Edit activity_main.xml

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 52

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 53

Four Heroes - Activity Add a Button widget

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 54

Four Heroes - Activity String file

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 55

Four Heroes - Activity R file

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 56

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 57

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 58

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 59

Four Heroes - Activity Add listener

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 60

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 61

Four Heroes - Activity Add new activity

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 62

Four Heroes - Activity Extend Activity

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 63

Four Heroes - Activity Right click →Source → Override…

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 64

Four Heroes - Activity Oncreate

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 65

Four Heroes - Activity IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 66

Four Heroes - Activity Write a name (e.g., activity02) Choose Relative layout

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 67

Four Heroes - Activity Design of activity02(e.g., back button)

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 68

Four Heroes - Activity Find it’s id Id is button1 (maybe not the

same as yours)

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 69

Four Heroes - Activity Setting your layout

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 70

Four Heroes - Intent Add new intent

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 71

Four Heroes - Intent Not work!? Why? No one knowyou create a new activity.

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 72

Four Heroes - Intent Android Manifest

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 73

Four Heroes - Intent IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 74

Four Heroes - Intent Declare a new activity.

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 75

Four Heroes - Intent Do the same thing to the

activity02, it will be able to switch back Mainactivity.

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 76

Four Heroes - Intent IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 77

Four Heroes - Intent IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 78

Four Heroes - Intent Another way, add a functionStartactivity02

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 79

Four Heroes - Intent Set button onclick in layout

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 80

Four Heroes - Service

IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 81

Four Heroes - Service IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 82

Four Heroes - Service IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 83

Four Heroes - Service IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Android Development Basic 84

Four Heroes - Service IRISIntelligent Robotics and Informatics System Lab

ZuoSyuan Wang

Recommended