mit global startup labs

22
MIT Global Startup Labs http://aiti.mit.edu Indonesia Summer 2013 Meetup 02 The Android SDK

Upload: others

Post on 13-Apr-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MIT Global Startup Labs

MIT

Global Startup Labs

http://aiti.mit.edu

Indonesia Summer 2013

Meetup 02 – The Android SDK

Page 2: MIT Global Startup Labs

Today‘s Meetup

• Recap of Yesterday

• Setting up the Android SDK

• A first glance at the Android Project Structure

• Your first project: „Hello World“

• Basic Layout Design

2

Page 3: MIT Global Startup Labs

3

Java Assessment(solutions posted on AITI site)

Page 4: MIT Global Startup Labs

3b) One Loop

4

static void assessmentThreeB()

{

String result = "";

for( int i = 1; i <= 6; i++ )

{

result += i;

System.out.println( result );

}

1

12

123

1234

12345

123456

Use one loop to printout the following:

Panji Gautama

Page 5: MIT Global Startup Labs

5) Using Methods

5

Write a code that

asks the user for a

number, and then

outputs the sum of

the individual digits

of that number, for

example if the user

inputs 23834, the

program should

output 20 (as

20=2+3+8+3+4).

package Assessment;

import java.util.*;

public class No5 {

public static void main(String[] args) {

int number = readInt(),sum=0;

while (number > 0)

{

sum += number%10;

number = number/10;

}

System.out.println(sum);

}

static int readInt()

{

Scanner scanner = new Scanner(System.in);

System.out.print("Enter an integer: ");

return scanner.nextInt();

}

} Haidar Muhamad

Page 6: MIT Global Startup Labs

6

Android SDK Installation

Page 7: MIT Global Startup Labs

Setting up the Android SDK

– Java JDK (Java Runtime not sufficient) http://www.oracle.com/technetwork/java/javase/downloads/

– Eclipse http://www.eclipse.org/downloads/

– Android SDK http://developer.android.com/sdk/index.html

– Eclipse ADT Plug-in http://developer.android.com/sdk/eclipse-adt.html

– Platforms (Android 2.1, 2.2, etc.)

– USB Driver (only needed for Windows)

– Emulator (Android Virtual Device)

7

AD

T B

un

dle

Page 8: MIT Global Startup Labs

The SDK Manager and Emulator

Eclipse: Window ->

• -> Android SDK

Manager

• -> Android Virtual

Device Manager

– Choose Nexus S

(works fastest)

8

Page 9: MIT Global Startup Labs

9

Android Project Structure

Page 10: MIT Global Startup Labs

Android Project Structure

10

Your Java Code goes in here, controls events

Automatically generated files, act as

„glue“ between .java and .xml files

Folders for graphic resources

Contains UI markup code

AndroidManifest.xml

First file to be excecuted, points to Java code and

contains system definitions/permission

Values are defined and labeled here

Page 11: MIT Global Startup Labs

The Layout File .xml

• Activities – one page of app, only one

main activity can exist

11

Graphical Layout

Page 12: MIT Global Startup Labs

Value Files .xml

12

Page 13: MIT Global Startup Labs

Activity File .java

13

Package declaration

Import statements

Extend Activity Class

Create UI (as defined in

Layout .xml)

Create Options Menu

Page 14: MIT Global Startup Labs

AndroidManifest.xml

14

Points to Activity File .java

Icon/ App name/

Style defined

Compatibility

Information

Page 15: MIT Global Startup Labs

Android App Build Process

15

Android

Manifest.

xml

.java

files

Layout

+

resourc

e files

.dex

files.apk

file

Please provide

the .apk file

when handing

in assignments

Page 16: MIT Global Startup Labs

16

Building a UI: Layouts

Page 17: MIT Global Startup Labs

Linear Layout

17

Position widgets vertically or horizontally

Note: Hardcoding

text not

recommended,

use string values

android:orientation

is an attribute that

can only be used

with linear layout

Page 18: MIT Global Startup Labs

Relative Layout

18

android:layout_below is an attribute that can be used only with

RelativeLayout. Other such attributes include layout_alignParentRight, and layout_toLeftOf.

Position widgets relative to each other: good for morecomplicated UIs

Page 19: MIT Global Startup Labs

Many more layouts and widgets…

19

• Button

• EditText (a text box)

• TextView (a text label)

• ListView

• GridView

• TabView

• Spinner (a drop-down menu)

• CheckBox

• RadioButton

• ToggleButton

• RatingBar

• MapView (for embedding Google Maps

objects in applications)

• WebView (for embedding web browsers

in applications)

• Linear Layout

• Relative Layout

• Grid Layout

• Frame Layout

• Table Layout

• Context Menu

• Option Menu

• Sub Menu

• Sliders

• Graphics

• Animations

• Videos

…which are furthermore all customizable

• Etc, etc, etc…

Page 20: MIT Global Startup Labs

Endless UI design possibilities

20

Android Interface Examples

Page 21: MIT Global Startup Labs

21

Today‘s Assignment

Page 22: MIT Global Startup Labs

Today‘s Assignment

Getting used to Android

• Set up the Android SDK on your Laptop

• Hack the „Hello World“ App

• Get used to layout design

Helpful links and documentation:

http://aiti.mit.edu/program/indonesia-summer-2013/

Let’s get started!

22