Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android."— Presentation transcript:

1 Android Boot Camp Demo Application – Part 1

2 Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android ADT, download SDK Manager packages Instructions are here: https://developer.motorolasolutions.com/communi ty/developer-events/appforum-2014/android- boot-camp/blog/2014/09/07/appforum-android- boot-camp--hands-on-lab

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

4 Take Default Options

5

6 Take Default Options, Create Blank Activity

7 Take Default Options

8 Basic “Hello world” Application is Generated

9 Create a “Run Configuration”

10 Run Configuration for Android Application

11 Browse to your project

12 Set the name of the Run Configuration to match your Application

13 Select an AVD or Android Device

14 Apply and Run

15 Application runs in Emulator

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

17 Add a Text Input Field (editText1)

18 Add a Button (button1) from “Form Widgets”

19 Define a Listener for “On Click” for the Button

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

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

22 Code Fragments 1 After: “public class MainActivity extends ActionBarActivity {” Insert: private TextView textOutput; private EditText textInput;

23 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; } });

24 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(""); }

25 Congratulations, you have completed your first Application!


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

Similar presentations


Ads by Google