Sei sulla pagina 1di 27

NSC Camp 26 October 2011

Basic Android Development


By Praramad Itthisan

NSC Camp 26 October 2011

Overview
Introduction

to Android Development Tools Android Application Development Break 20 mins. User Interface Basic Layout Launch 1 hr.

NSC Camp 26 October 2011

Introduction to Android

NSC Camp 26 October 2011

Android Component

NSC Camp 26 October 2011

Development Tools
Eclipse Android SDK ADT Plugin for Eclipse
http://developer.android.com/resources/tut orials/hello-world.html

NSC Camp 26 October 2011

Install a Platform

In the Android SDK and AVD Manager, choose Available Packages in the left panel. In the right panel, expand the Android Repository list to display the components available for installation. Select at least one platform to install, and click Install Selected. If you aren't sure which platform to install, use the latest version.

NSC Camp 26 October 2011

Create an AVD

In Eclipse, select Window > Android SDK and AVD Manager. Select Virtual Devices in the left panel. Click New.... The Create New AVD dialog appears. Type the name of the AVD, such as "my_avd". Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.3.3) you want to run on the emulator. For this tutorial, choose the latest platform that you have installed and ignore the rest of the fields. Click Create AVD.

NSC Camp 26 October 2011

Create a New Android Project

NSC Camp 26 October 2011

Create a New Android Project

10

NSC Camp 26 October 2011

There is a common file structure for applications


Code Auto generated resource list files

images
UI layouts constants Control Application

11

NSC Camp 26 October 2011

Work 1
Change
Hello World, MainActivity!

Add

strings.xml

12

NSC Camp 26 October 2011

toast

13

NSC Camp 26 October 2011

toast
Toast.makeText(getBaseContext(),R.string.hello,Toast.LENGTH_SHORT).show();

Toast.makeText(getBaseContext(),"test",Toast.LENGTH_LONG).show();

14

NSC Camp 26 October 2011

onKeyDown
public boolean onKeyDown(int keyCode, KeyEvent event) { switch(keyCode){ case KeyEvent.KEYCODE_0: Toast.makeText(getBaseContext(),"0",Toast.LENGTH_SHORT).show(); return true; case KeyEvent.KEYCODE_1: Toast.makeText(getBaseContext(),"1",Toast.LENGTH_SHORT).show(); return true; } return false; }

15

NSC Camp 26 October 2011

Work 2

0-9 toast

16

NSC Camp 26 October 2011

17

NSC Camp 26 October 2011

User Interface

18

NSC Camp 26 October 2011

User Interface

19

NSC Camp 26 October 2011

Work 3

Objects App Object

20

NSC Camp 26 October 2011

Basic Layout

Linear Layout Relative Layout

Frame Layout Table Layout

21

NSC Camp 26 October 2011

Linear Layout

22

NSC Camp 26 October 2011

Frame Layout

23

NSC Camp 26 October 2011

Relative Layout

24

NSC Camp 26 October 2011

Table Layout

25

NSC Camp 26 October 2011

Layout

26

NSC Camp 26 October 2011

Work 4

login form

27

NSC Camp 26 October 2011

Potrebbero piacerti anche