Top Banner
Android Boot Camp Demo Application – Part 1
25

Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Dec 13, 2015

Download

Documents

Godfrey Norman
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Android Boot Camp

Demo Application – Part 1

Page 3: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Create a new Android Project, in this case, the name is “Appforum1”

Page 4: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Take Default Options

Page 5: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Take Default Options

Page 6: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Take Default Options, Create Blank Activity

Page 7: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Take Default Options

Page 8: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Basic “Hello world” Application is Generated

Page 9: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Create a “Run Configuration”

Page 10: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Run Configuration for Android Application

Page 11: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Browse to your project

Page 12: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Set the name of the Run Configuration to match your Application

Page 13: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Select an AVD or Android Device

Page 14: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Apply and Run

Page 15: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Application runs in Emulator

Page 16: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Go back into the graphical layout designer, Select Text Fields Tab

Page 17: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Add a Text Input Field (editText1)

Page 18: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Add a Button (button1) from “Form Widgets”

Page 19: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Define a Listener for “On Click” for the Button

Page 20: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Add the definitions for “textOutput” and “textInput”Add the code to get the references to the XML objectsAdd the code to get keystrokes, use “Ctl”-”Shift”-”O” to Organize Imports

Page 21: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Add code for button and to move text from input to output fields

Page 22: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Code Fragments 1

After: “public class MainActivity extends ActionBarActivity {”

Insert:

private TextView textOutput; private EditText textInput;

Page 23: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Code Fragments 2

After: “protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);”

Insert:

textOutput = (TextView)findViewById(R.id.textView1); textInput = (EditText)findViewById(R.id.editText1); textInput.setOnKeyListener(new EditText.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) {

if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) TransferInput(); return false; }

});

Page 24: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Code Fragments 3

At the end of your application before the final “}”, insert :

public void Button1Clicked (View v) {

TransferInput(); } public void TransferInput(){ String input; input = textInput.getText().toString();

textOutput.setText(input); textInput.setText(""); }

Page 25: Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.

Congratulations, you have completed your first Application!