Android application building. [outofbook.info]

39
Welcome to Android application development START

description

in this slides 1. how to creat new project 2. how to run your application? 3. creating Hello world project 4. how to create button. 5. on click effect. 6.under standing code (example code is given)

Transcript of Android application building. [outofbook.info]

Page 1: Android application building. [outofbook.info]

Welcome to Android application development …

START

Page 2: Android application building. [outofbook.info]

Create a Project with Eclipse

1

In the window that appears, open the Android folder, select Android Application Project, and click Next.2

Click New in the toolbar

skip

Page 3: Android application building. [outofbook.info]

3

Here we go…

Now we will fill the form that appears.

Application Name is the app name that appears to users.

For this project, use “myaap"

Project Name is the name of your project directory and the name visible in Eclipse.

skip

Page 4: Android application building. [outofbook.info]

3

Here we go…

Now we will fill the form that appears.

Package Name is the package namespace for your app.

Your package name must be unique across all packages installed on the Android system.

For this project, you can use something like "com.example.myaap"

skip

Page 5: Android application building. [outofbook.info]

3

Here we go…

Now we will fill the form that appears.

Minimum Required SDK is the lowest version of Android that your app supports, indicated using the API LEVEL.

To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set.

Target SDK indicates the highest version of Android (also using the API LEVEL) with which you have tested with your application.

skip

Page 6: Android application building. [outofbook.info]

3

Here we go…

Now we will fill the form that appears.

Compile With is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK.

You can still build your app to support older versions, but setting the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.

skip

Page 7: Android application building. [outofbook.info]

3

Here we go…

Now we will fill the form that appears.

Theme specifies the Android UI style to apply for your app. You can leave this alone.

Click Next.

skip

Page 8: Android application building. [outofbook.info]

4

Here we go…

On the next screen to configure the project, leave the default selections

and click Next.

skip

Page 9: Android application building. [outofbook.info]

The next screen can help you create a launcher icon for your app.5

You can customize an icon in several ways

You can also add your own icon by selecting BROWSE button.

Then Click Next.

skip

Page 10: Android application building. [outofbook.info]

6

Then Click Next.

Now you can select an activity template from which to begin building your app.

For this project, select BlankActivity.

skip

Page 11: Android application building. [outofbook.info]

7 Leave all the details for the activity in their default state and click Finish.

skip

Page 12: Android application building. [outofbook.info]

Your Android project is now set up with some default files and you’re ready to begin building the app.

Continue to the next lesson.

skip

Page 13: Android application building. [outofbook.info]

HOW TO RUN YOUR APPLICATION?skip

Page 14: Android application building. [outofbook.info]

Run Application on your Android Mobile Phone

Plug in your device with a USB cable.

Enable USB debugging on your device.On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.

On Android 4.0 and newer, it's in Settings > Developer options.

Now click Run from the toolbar

1

2

3

skip

Page 15: Android application building. [outofbook.info]

In the Run as window that appears, select Android Application and click OK.

Run Application on your Android Mobile Phone

Steps 1

Click here to view bigger image

Click here to quit image

Select your

mobile then click OK

This type of screen you can see in your mobile phone.

(after Creating Project)

skip

Page 16: Android application building. [outofbook.info]

HELLO WORLD

HELLO WORLD

we will create a project name HELLO WORLD.

skip

Page 17: Android application building. [outofbook.info]

Create a project name My aap1.1 Refer “how to create project”

skip

Page 18: Android application building. [outofbook.info]

After creating a project u can see this type of screen

skip

Page 19: Android application building. [outofbook.info]

2

Now connecty o u r d e v i c e w i t h

Computerrun your application.

&

Refer “how to run application”

skip

Page 20: Android application building. [outofbook.info]

Adding Button

Creating a Button

skip

Page 21: Android application building. [outofbook.info]

1 On the left hand side you can see “Button ” option.

skip

Page 22: Android application building. [outofbook.info]

2

button

Click the button and drag on the app window where you want to put.

Now the button is

created.

skip

Page 23: Android application building. [outofbook.info]

EditButton Click here

B u tt o nTextskip

Page 24: Android application building. [outofbook.info]

1

Double click

on the button orClick on “activity_main.xml”

skip

Page 25: Android application building. [outofbook.info]

2 This type of window will appear.

Edit Code:

A n d r o i d : t e x t = “ Button” / >

A n d r o i d : t e x t = “ Click here” / >

skip

Page 26: Android application building. [outofbook.info]

3 Click on “graphics Layout” and see the result.

skip

Page 27: Android application building. [outofbook.info]

On Click Effect

skip

Page 28: Android application building. [outofbook.info]

1 First create a butt on. Refer “adding button”

skip

Page 29: Android application building. [outofbook.info]

2 C r e a t e a .XML File. New/android XML fileG o t o

skip

Page 30: Android application building. [outofbook.info]

2 C r e a t e a .XML File. New/android XML fileG o t o

This window will appear.

Resource Type: It is a folder location where your new XML file will placed.

Project: Your current project name.

File: Give your file name

skip

Page 31: Android application building. [outofbook.info]

2 C r e a t e a .XML File. New/android XML fileG o t o

This window will appear.

Project: Your current project name.

File: Give your file name

click

Now give File name

“Click”

Now Click “Finish”

Resource Type: It is a folder location where your new XML file will placed.

skip

Page 32: Android application building. [outofbook.info]

Now your file is created in following location.

1 2 3 4

Folder Location

Go to Myaap > res > layout > click.xml

skip

Page 33: Android application building. [outofbook.info]

Now double click on click.xml file.3

This type of window will appear Drag and drop “ LARGE ” text to your app window.

LARGELARGE

skip

Page 34: Android application building. [outofbook.info]

Edit “ LARGE ” text and rewrite “ Making Project ”.4

Double click on the text and the following window will appear.

Edit text :

android:text=“large” to “making project”

skip

Page 35: Android application building. [outofbook.info]

Now go to MainActivity.java5

& we will now write the code for

on click effect.

skip

Page 36: Android application building. [outofbook.info]

setContentView() sets the layout for the Activity. It includes Buttons, TextViews, etc

Understanding the code.

R.layout.activity_main This is your layout,(actually this is location of the file where activity_main.xml file is situated,R= resource folder / layout folder / activity_main.xml)

findViewById(R.id.button1);It will find button1

@OverrideIt will reject the common errors and run your application.

public void onClick(View v) {setContentView(R.layout.click);If user click on button then another page will appear ( click.xml ).

setContentView(R.layout.click);this will open the page located in (R.layout.click)

Following is the code for “on click action “.

skip

Page 37: Android application building. [outofbook.info]

Click the green button and copy the code and paste it into your

mainactivity.java

skip

Page 38: Android application building. [outofbook.info]

Finally Run your application in your

mobile or immulator.

skip

Page 39: Android application building. [outofbook.info]

1

skip