Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at

Slides:



Advertisements
Similar presentations
Customizing the MOSS 2007 Search Results November 2007 Rafael Perez.
Advertisements

Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Word Processing First Steps
XP Tutorial 4 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Personalizing Your Windows Environment Tutorial 4.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Microsoft ® Office PowerPoint ® 2003 Training Playing movies [Your company name] presents:
How to make it work? Doncho Minkov Telerik Academy academy.telerik.com Technical Trainer
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Android Application Development 2013 PClassic Chris Murphy 1.
Better reference the original webpage :
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Introducing the Sudoku Example
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Basic Android Tutorial USF’s Association for Computing Machinery.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
Eclipse Tutorial Barrett Summer Scholars 2011 Sustainable Engineering: Learning to Engineer Truly Green Products.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
File Management Presented to The Glades Computer Club January 4, 2001.
Android Boot Camp for Developers Using Java, 3E
ACTIVINSPIRE TRAINING Tips and tools for creating Flipcharts on ActivInspire.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Unit 1: Java and Eclipse The Eclipse Development Environment.
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
Android Hello World 1. Click on Start and type eclipse into the textbox 2.
The Next Generation. Parent Access Grade History and Attendance.
First Venture into the Android World Chapter 1 Part 2.
Fall 2003Sylnovie Merchant, Ph.D. ACCESS Tutorial Note: The purpose of this tutorial is to provide an introduction to some of the functions of ACCESS in.
New Activity On Button Click via Intent. App->res->Layout->Blank Activity A new xml file is created and a new class is added to java folder. In manifest.xml.
Page Designer Storyboard J. A. Fitzpatrick December 2004.
Creating and Editing a Web Page
Photoshop Actions Lights, Camera, Actions in Photoshop.
Intoduction to Andriod studio Environment With a hello world program.
If you don’t have Google Earth downloaded already, you can go to to get it.
Opening a File 1.Open Word 2.Click the Microsoft Office button(Very top left hand corner). A menu appears 3.Click Open. The Open dialog box appears 4.Use.
1. Using word you can create the document and edit them later, as and when required,by adding more text, modifying the existing text, deleting/moving.
Editing and Debugging Mumps with VistA and the Eclipse IDE Joel L. Ivey, Ph.D. Dept. of Veteran Affairs OI&T, Veterans Health IT Infrastructure & Security.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Android Programming.
Chapter 2: Simplify! The Android User Interface
Introduction to android
Android Introduction Hello World
Android Application Development 1 6 May 2018
Android N Amanquah.
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Android Introduction Hello World.
Anatomy of an Android Application
Android Studio Hello World
How to PostPower Point Presentations
European Computer Driving Licence
Presentation transcript:

Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at – Don’t do anything under the section “Construct the UI” Alternatively, you can do the step “Construct the UI.” But then, redo the “Create an AVD” and “Create a New Android Project.” After Creating the AVD, start the AVD – In eclipse, menu Window -> AVD Manager. – Select the emulator, and then select start – It takes quite along time for the emulator to start Run App – Right click on HelloAndroid in the package Explorer – Select Run As -> Android Application – A dialog box opens showing a list of places where the app can run. Select the device or emulator – If an emulator is not running and there is no device, the emulator will start (assuming that one is defined) – If using the emulator, bbe sure that the emulator is unlocked. It will lock like your phone if idle for a while

Adjust font size open res/layout/main.xml See xml and layout (select toward the bottom) (Note the outline view at the far right – Might need to click on button on right edge) Expand linear layout On graphic, right on “Hello World…” – Other properties -> inherited from textView -> text size set text size to 18pt Save and rerun – If the emulator is idle, it will lock. Unlock to run app – Run by pressing the green arrow near the top of eclipse Note that when you hover over the green arrow, it says Run HelloAndroid ((Does logcat appear in java: Window -> Preferences -> Android -> Logcat - > Display logcat view when there are messages from an application in the workspace))

Add button In layout/main.xml Along left is Palette Play with palette views with down arrow – I like show icons only Find button and drag to graphical view Change id – Right click and select Edit Id – Set it to ChangeActivityButton Change text – The right way is to define a string. – The fast way Switch to main.xml Locate <Button … Locate android:text=“button” Change to – android:text=“Change View” Run

Display short message when button is pressed Open src/com.example.helloandroid.java Let’s understand what is already there – HelloAndroid extends Activity: We’ll learn more about activities later. But all activities must be extend Android.app.Activity – setContentView(R.layout.main); will make the view. Note that R.layout.main refers to the main.xml layout where we changed the font size and added the button. But R is a class that the android plugin automatically creates when anything under /res is saved (so you might need to save before r is valid). So R is a provides an interface between the resources (e.g., xml files) and your program After “setContentView(…);”, add – final Button button = (Button) findViewById(R.id.ChangeActivityButton); – Note that Button is red underlined (an error). Click on button. Import Button. Expand import.. To see that button has been included Add – button.setOnClickListener(new View.OnClickListener() { – public void onClick(View v) { – // Perform action on click – Toast.makeText(HelloAndroid.this, "clicked", Toast.LENGTH_SHORT).show(); – } – }); Run Instead of Toast…, put Log.e("DebugInfo","button pressed"); Why in Toast… do we have HelloAndroid.this. What is this?, why not just this?

Make a new activity (so we can flip between activities)

Activities An app is composed of tasks each with its own screen. These tasks referred to as activities. – Activity is composed to some actions (code), and a view – The code is defined by a java class, while the view is defined by an xml file. – The java code controls the screen, and hence which xml file is used The system and your activity – How does an activity become active? The OS can start it Another activity can start it – How does the activity end The OS can end it It can end itself The first activity (the one that is active when the app starts) is the one that is given in the app’s manifest as follows <activity android:name=".HelloAndroid" These say that this class is the entry point into the app. That is, the OS can call this activity by using the name and category. This particular name and category means it is the entry point This is a class name in the package

Make a new view Add layout of view – On the left right click on /res/layout. – Select new -> other-> Android->Android XML Layout file – Call file view2 (name must be all smalls, no caps) – Leave it as Layout resource – Leave LinearLayout as root element – Next/finish

layout view Drag a large textview – Change text to View2 Drag a button – Change text to “go to other view” – Change ID to GoToOtherView

Add a class to show this view Right click on edu.udel.eleg454.HelloAndroid Select new -> class Set Name to SecondView Set superclass to.. – Check what helloAndroid is extended from – android.app.Activity – Set super class to android.app.Activity Finish

Add text to SecondView First open HelloAndroid Paste in to the same place on SecondView Delete the button stuff Change – setContentView(R.layout.main); – To – setContentView(R.layout.???); Go back to /res/layout. What is the name of the xml file we just added? view2 setContentView(R.layout.view2); Recall that the layout is an xml file. But R is a class that is automatically generated from the resources (including xml files) R.layout.mmmm “uses” res/layout/mmmm.xml R.id.joe is the id of resource with id called joe. – The xml file has … …. – Note that we used the for getting the button object

Make View2 into an activity that can be called The OS will call (e.g., start) activities The app must advertise the activities that can be called and must detail how they are referenced (what name to use to call them) This is done in the Manifest (the manifest does many other things as well) Edit manifest to allow View2 to be started Open androidManifest.xml – Explore all the things – Check out Permission tab. This is where an app can request permission to use various resources, like GPS or the network. Select the Application tab – Go to Application Nodes (lower left area) – Select add Select radio button “Create a new element at the top level, in Application” Select Activity Highlight the newly added activity On the right, change name to SecondView. Or select browse to find the view. Leave other fields empty Now, under application nodes it says SecondView (Activity) (maybe after saving) Under application nodes click add Select radio button “Create new element in the selected element, Application > OtherView (Activity) Select Intent Filter Now Intent Filter has been added. Leave the fields on the right empty Under the application nodes highlight the newly added Intent Filter Click Add Select Action In the attributes for Action (on the right), set name to edu.udel.eleg454.helloandroid.ShowSecondView – This is the name that we made up. This app (and other) can call the activity by this name Under Application Nodes select newly added Intent Click Add Select Category In drop down list, select android.intent.category.DEFAULT Save

Call View2 when button in main view is clicked Open HelloAndroid.java under src/com.example.helloandroid Recall that Toast is executed on the button press. Now let’s add something to run the other view. Just below Toast.makeText(…); add String actionName = "edu.udel.eleg454.helloandroid.ShowSecondView"; Intent intent = new Intent(actionName); startActivity(intent); Since Intent is underlined in red, hover over and select import Now save and run Press button

Closing view2 You can close view2 with the “go back” button Or, add a “close” button, Button closeViewButton = (Button)findViewById(R.id.closeViewButton); closeViewButton.setOnClickListener(new View.OnClickListener() public void onClick(View v) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); }});

add a new string to /res/strings.xml – Open strings.xml – View the resources view (as oppose to the xml view) – Select Add – Select String – Set name otherString – Set Value This is the second view

Edit view2 Open /res/layout/view2.xml (if it is not already open) Go to layout view (not xml) On far right, select LinearLayout Click green + Select TextView, ok Highlight TextView on far right Open properties (tab toward the bottom) Scroll through textView to Text. Select browse and select otherString (the one we just added)