android application development stephen diniz sdiniz@umassd.edu computer/electrical engineer lecture...

Post on 21-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

AndroidApplicationDevelopment

Stephen Dinizsdiniz@umassd.eduComputer/Electrical Engineer

Lecture 01

Introduction

Setting Up Your IDE An IDE is an Integrated Development

Environment and is made to aid developers in creating and debugging projects.

IDE’s typically include syntax highlighting, a debugger, auto-completion, and a solution builder.

Java’s JDK Like any programming language,

development kits are required in order for your computer to compile and interpret your code.

Since Android is heavily based off Java, most concepts can be directly implemented during your development.

http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

Eclipse Eclipse is a very powerful IDE and is

recommended by Google to use when developing for Android.

http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigor

Step 1: Install the Java JDK Go to the provided link on slide 3 and

download the version of the JDK that best fits your operating system.

For Windows Vista/7 users running the 64-bit operating system, make sure to download the Windows x64 version of the Java Development Kit.

Step 2: Downloading Eclipse Eclipse, like the Java JDK, comes in

Linux/Window/Mac builds (32-bit/64-bit).

Choose the one that best fits you and unzip it.

The most convenient place to have Eclipse is in your root directory:

C:\Eclipse -Windows/home/user/eclipse/ -Linux

Step 3: Installing the ADT The ADT, or Android Development

Tools, is a plugin for Eclipse designed to give powerful integration to your environment.

The most recent version of the ADT (as of 9/21/11) is ADT 12.0.0

The ADT installation instructions can be found here:

http://developer.android.com/sdk/eclipse-adt.html

The Java Programming Language Primitive Data Types: (notice lowercase)

byte short int long float double boolean char

The Java Programming Language Objects

String BigDecimal

Require methods in order to do most things, such as finding out if two strings are equal.

Incorrect Correct

Java “Hello world!” Program

http://www.thenewboston.com/?cat=36&pOpen=tutorial

Java Tutorials:

Android “Hello world” Application Programmatically:

Android “Hello world” Application Utilizing XML:

Android “Hello world” Application Utilizing XML (continued):

The Result is identical

Which Approach To Use? Mostly preference, however… For larger, more complex applications, I

would highly recommend the XML approach

XML makes it easy to modify properties of Objects on the screen (Buttons, TextViews, etc) For larger, more complex applications, I would highly recommend the XML approach

Do I have to choose? No, for the most part, XML and the code

play nicely together. Accessing an object in an XML file

requires one line of code and its attributes can be read and modified.

For Example Let’s return to the second Hello world

example and modify the TextView’s content.

The XML file will go unchanged, but note the TextView’s android:id

Binding to the TextView The following code will bind to the Hello

world’s TextView and change its contents to “Android is Awesome!”

android:id

The Android Developer Reference Website This website contains all the information

about Android methods and objects in order to do things programmatically.

Most methods (that refer to XML objects) can be altered via XML and Java relatively easily.

http://developer.android.com/reference/android/provider/package-summary.html

Using the Reference Website Let’s look up how to create a text field,

or in Android, an EditText

We’re going to search EditText in the search field and choose the android.widget.EditText option.

Using the Reference Website If you scroll down a bit you’ll find a

section called Public Methods.

Using the Reference Website Let’s make a simple App that will get

the content of an EditText, mirror the String, and set the EditText’s content to the new, mirrored String.

Any ideas?

String Mirroring App

Note: getText() returns an Editable object.

If we click the Editable link and read up quickly, we’ll notice Editable “implements” GetChars, Spannable, Appendable, and most importantly (for this project), CharSequence

String Mirroring App Let’s scroll down to the Inherited Methods and see

what methods are available “From interface android.text.CharSequence

In this case, the method of interest is toString() because of its return type String.

String Mirroring App Perfect, we have two functions,

getText() and setText() to do that main operations we want to our EditText object.

The rest of the mirroring is purely Java and can be done in a few different ways.

String Mirroring App

String Mirroring App

top related