Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling
|
|
- Malcolm Hampton
- 6 years ago
- Views:
Transcription
1 Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling
2 Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity? When should you make changes to R.java? Give an example of a View (something in Android that extends View) How to add a new XML Layout file?
3 Today's Agenda Layouts LinearLayout, RelativeLayout, TableLayout Widgets TextView, EditText, Buttons, SeekBar, NumberPicker Toasts Event Handling
4 Views Every UI component in Android is a View
5 Layouts Layouts are ViewGroups Special types of Views that contain other Views or ViewGroups Your XML file will contain a hierarchy of Views You can add multiple Layouts to the canvas! Properties/Attributes of Views are configurable normally prefixed with android: e.g. android:id, android:text
6 Layouts How do we create our layouts? Programmatically Defined in XML Allows separation of behavioral code from presentation Allows visualization of layout design How do we associate a layout with an Activity? Typically done with a call to the setcontentview() method in the oncreate() implementation
7 Layouts LinearLayout RelativeLayout TableLayout TabLayout
8 Layouts - LinearLayout Review Only allows you to arrange widgets in a linear direction horizontally or vertically sometimes this is all you need!
9 Layouts - LinearLayout (Vertical) A
10 Layouts - LinearLayout (Vertical) A B
11 Layouts - LinearLayout (Vertical) A B C
12 Layouts - LinearLayout (Vertical) A B C D
13 Layouts - LinearLayout (Vertical) A B C D E
14 Layouts - LinearLayout Nesting LinearLayouts can degrade performance For your homeworks and projects, only use LinearLayout when you have good reason to do so
15 Layouts Try not to waste too much time on editing the Layout in the XML editor If you want to switch from LinearLayout to another Layout Right click canvas Change Layout... Select a different Layout
16 Layouts Want to add an entirely new UI? Right click your project New > Android Resource File Resource Type: Layout File: xml_file_name.xml Root Element: e.g. RelativeLayout This stores the new XML file in res/layout Android Studio will automatically set layout as the directory that the resource file should be created in
17 Layouts - RelativeLayout Allows you to specify the position of one View B relative to another View A
18 Layouts - RelativeLayout A
19 Layouts - RelativeLayout A B
20 Layouts - RelativeLayout A B
21 Layouts - RelativeLayout B A
22 Layouts - RelativeLayout B A
23 Layouts - RelativeLayout B A Many possibilities! Unlike LinearLayout
24 Layouts - RelativeLayout A B Many possibilities! Unlike LinearLayout
25 Layouts - RelativeLayout B A Many possibilities! Unlike LinearLayout
26 Layouts - RelativeLayout Many more possibilities for arranging your widgets, unlike LinearLayout RelativeLayout > LinearLayout Skip this tutorial and use the WYSIWYG editor instead to save time!
27 Layouts - TableLayout Displays widgets in rows and columns similar to HTML tables Your TableLayout usually consists of TableRows, which lay their children out horizontally layout_width attribute of TableLayout's children are forced to be match_parent (even if you set it yourself) Likewise, layout_height of a TableRow is forced to be wrap_content
28 Layouts - TableLayout TableRow TableRow A D B C TableRow
29 Layouts - Oversized Layouts If you have some widgets that aren't being displayed on the screen, it could be because there isn't enough space on the screen to show them all You won't be able to scroll by default
30 Layouts - ScrollView To solve this: Add a ScrollView view to the root of your root layout (can be LinearLayout) Move your main Layout to root of the ScrollView (e.g. RelativeLayout)
31 Widgets - Finding Available Widgets To see some of the available Widgets, open one of the XML files in res/layout View the XML file as Graphical Layout using the tabs at the bottom of the window Select a category in the left pane if necessary (e.g. Text Fields)
32 Widgets All of these widgets are subclasses of the View class (i.e., View is the base class for widgets) Try to avoid modifying XML files directly if you can use Forms or WYSIWYG "wizzy wig" instead
33 Widgets - Examples TextViews Displays text in your Activity EditText Allows the user to input text Button Can be pressed by the user to perform an action CheckBox RadioGroup ToggleButton
34 Widgets - Id's Id's are not required for each widget R.java stores the id's for your widgets. How do the id's get set? Remember, don't edit the R.java file!
35 Widgets - Id's 2 ways to add a widget and set its android:id value 1. Using the Graphical Layout editor a. Drag and drop a widget onto the canvas b. Set the id property in the Properties section of the Component Tree 2. Using the XML editor a. Type the XML code needed for the widget that you want b. add android:id="@+id/id_name" to its attributes
36 Widgets - Id's Save your file, and the id will automatically be added to R.java tells the XML parser to expand the rest of the id string and treat it as an ID resource + is what causes the id to be added to R.java
37 Widgets As you may have noticed, you can do this for attributes other than the android:id attribute You can explore your options by right clicking on anything on the canvas
38 Widgets - layout_height/width Always set the android:layout_height and android:layout_width attributes in the XML file for your widgets. NOT doing so is an easy way to get a Force close Drag and drop onto the canvas so that you don't have to worry about this
39 Widgets - layout_height/width Values for android:layout_height and android:layout_width "wrap_content" big enough to hold its contents "match_parent" make the specified dimension as big as its parent "fill_parent" being deprecated, replaced by "match_parent"
40 Widgets - TextView We will experiment with some of the attributes for the TextView widget android:text e.g. "Hello World!" android:textsize e.g. "20sp" sp = scale-independent pixels, it helps when writing apps to be run across a variety of device configurations android:textstyle e.g. "italic" android:textcolor e.g. #FFFFFF
41 Widgets - EditText Experimenting with the EditText widget. EditText is a subclass of TextView - adds the ability to edit text. android:hint e.g. "Enter your name" android:inputtype textcapwords textmultiline textnosuggestions (doesn't work for me, try textvisiblepassword as a workaround) textpassword number Can be combined using e.g. android:inputtype= textcapwords textmultiline
42 Widgets - Button Experimenting with the Button widget. Button is a subclass of TextView. android:onclick e.g. dosomething Different button types Button for a button with text ImageButton for a button with just an icon Button for a button with an icon and text add android:drawableleft attribute
43 Widgets - CheckBox Experimenting with the CheckBox widget. CheckBox is a subclass of Button android:text e.g. "I agree to the terms and conditions" android:checked "true" or "false" sets the default value of the CheckBox
44 Widgets - RadioGroup / RadioButton You usually want to drag a RadioGroup onto the canvas first It's easy to drag and drop or remove RadioButtons to/from the RadioGroup
45 Widgets - RadioButton Experimenting with the RadioButton widget. RadioButton is a subclass of Button android:text e.g. "Female" android:checked "true" or "false" sets the default state/value of the RadioButton
46 Widgets - ToggleButton Experimenting with the ToggleButton widget. ToggleButton is a subclass of Button android:texton e.g. "GPS Enabled" default value is "On" android:textoff e.g. "GPS Disabled" default value is "Off" android:checked "true" or "false" sets the default state/value of the ToggleButton
47 Widgets - Switch Introduced in Android 4.0 as an alternative to ToggleButton Requires the minimum supported API to be Android 4.0
48 Widgets - SeekBar Experimenting with the SeekBar widget. android:max e.g. "100" you can't set the min, it's always 0 android:progress e.g. "50" sets the current position of the slider on the SeekBar
49 Widgets - RatingBar Experimenting with the RatingBar widget. android:numstars e.g. "6" android:rating e.g. "3" sets the default rating android:stepsize e.g. "2" rating is set in groups of stepsize default = "1"
50 Widgets - NumberPicker NumberPicker is in HoneyComb (Android 3.0) or later You may get a Force close if you try to manipulate it in an earlier version
51 Widgets - NumberPicker For some reason, it doesn't seem like NumberPicker attributes can be set in XML...
52 Widgets - NumberPicker After adding NumberPicker with android:id="@+id/agepicker" to the XML file NumberPicker magepicker; public class HelloWorldActivity extends public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); magepicker = (NumberPicker) findviewbyid(r.id.agepicker); magepicker.setmaxvalue(120); magepicker.setminvalue(5); } }
53 Widgets Most, of a widget's XML attributes can be set and get programmatically Example widget XML attribute set method get method EditText android:text settext(string) gettext() Button android:onclick setonclicklistener( OnClickListener) - CheckBox android:checked setchecked() ischecked() SeekBar android:progress setprogress() getprogress() SeekBar android:max setmax() getmax()
54 Toast Finally, Java code Before looking at Toasts... let's look at the auto-generated Java code. public class HelloWorldActivity extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } }
55 Toast Finally, Java code Before looking at Toasts... let's look the auto-generated Java code. public class HelloWorldActivity extends Activity { public void oncreate(bundle savedinstancestate) { } Main point of entry into your code. Called when the Activity is created. super.oncreate(savedinstancestate); setcontentview(r.layout.main);
56 Toast Finally, Java code Before looking at Toasts... let's look the auto-generated Java code. public class HelloWorldActivity extends Activity Android needs to do who knows what before you can do anything. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } }
57 Toast Finally, Java code Before looking at Toasts... let's look the auto-generated Java code. public class HelloWorldActivity extends Activity Set the layout that you want to use. This one public corresponds void oncreate(bundle to savedinstancestate) { res/layout/main.xml super.oncreate(savedinstancestate); setcontentview(r.layout.main); } }
58 Toast A notification message that is displayed on the screen for a specified time (usually fraction of a second or seconds) Add this to your code: Toast.makeText(this, "Message", Toast.LENGTH_SHORT).show();
59 Toast There are several reasons why your Toast won't show up on the screen One reason is that you probably forgot the.show() part of the Toast code.
60 Events - Event driven programming Android is event-driven The flow of code depends on events, unlike programs you normally write in C++ If you've written JavaScript code before then you've probably done event-driven programming
61 Events - examples events Call a method when the user clicks a button checks a checkbox pulls back on and lets go of slingshot in Angry Birds Call a method when the system receives an SMS receives a phone call completely loads a web page in the browser
62 Events - View Every View can react to the onclick event Layouts are also Views!
63 Events - Button Click Let's react to a Button click event. Add a button to the canvas, and add the code in bold below to the button <Button android:text="submit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onclick="myeventhandler" />
64 Events - Button Click Let's react to a Button click event. Add a button to the canvas, and add the code in bold below to the button <Button android:text="submit" This says to launch the myevent method when this button is clicked android:layout_width="wrap_content" android:layout_height="wrap_content" android:onclick="myeventhandler" />
65 Events - Button Click Let's react to a Button click event. Add the method below to your Java code public void myeventhandler(view v) { } Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show();
66 Events - Button Click Let's react to a Button click event. Name of the method Add the method must match below the to your Java code public void myeventhandler(view v) { } android:onclick attribute in the XML file Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show();
67 Events - Button Click Let's react to a Button click event. Has to be public to be Add able to work. the private method below to your Java code may give you a Force close. public void myeventhandler(view v) { } Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show();
68 Events - Button Click Let's react to a Button click event. void for onclick. Not all Add event-handlers the method should below to your Java code public void myeventhandler(view v) { } return void, however. We'll see this soon Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show();
69 Events - Button Click Let's react to a Button click event. View parameter is Add the method below to your required. Java You may code use public void myeventhandler(view v) { } Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show(); myeventhandler to handle multiple events.
70 Events - Button Click Let's react to a Button click event. How do you know Add the method below to your Java code public void myeventhandler(view v) { } Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show(); which view has been clicked?
71 Events - How do we know which view has been clicked? So far we've done most of our development using XML. Now we're going to really start looking at Java code. We need to be able to reference our views (specified in the XML file) using Java In the Graphical Layout, use the Properties view to set the ID of the Button to "submitbutton"
72 Events - How do we know which view has been clicked? Add an EditText to the canvas Set the ID to "firstname" Set android:onclick="myeventhandler"
73 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText mfirstname; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
74 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText mfirstname; Add local fields for the corresponding widgets to reference them public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
75 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText Set the widgets. Remember we set the public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); unique IDs for these widgets previously. setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
76 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText Cast it to the correct View subclass, since findviewbyid returns a View. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
77 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText Now that you can reference the views in Java, take a look at the methods for the views public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
78 Events - How do we know which view has been clicked? public class HelloWorldActivity extends Activity { Button msubmitbutton; EditText e.g. msubmitbutton.settext("submit"); msubmitbutton.gettext(); This is important! public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msubmitbutton = (Button) findviewbyid(r.id.submitbutton); mfirstname = (EditText) findviewbyid(r.id.firstname); }
79 Events - How do we know which view has been clicked? public void myeventhandler(view v) { } Toast.makeText( this, "You pressed a button!", Toast.LENGTH_LONG).show(); How do you know which view has been clicked?
80 Events - How do we know which view has been clicked? public void myeventhandler(view v) { if (v == msubmitbutton) { /* submitbutton clicked */ } else if(v == mfirstname) { /* first name clicked */ } }
81 Events - How do we know which view has been clicked? public void myeventhandler(view v) { } Add this method to your class if(v == msubmitbutton) { /* submitbutton clicked */ } else if(v == mfirstname) { /* first name clicked */ }
82 Events You can also create a different method to handle events for different views if you want to.
83 Events - Handling Events There are 3 ways to incorporate EventListeners: 1. Specify the name of the method to handle the event in XML. We just did this. 2. Have your Activity implement an EventListener 3. Create an anonymous implementation of the EventListener
84 Events - Handling Events There are 3 ways to incorporate EventListeners: 1. Specify the name of the method to handle the event in XML. We just did this. 2. Have your Activity implement an EventListener 3. Create an anonymous implementation of the EventListener
85 Events - Implement EventListener public class HelloWorldActivity extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button msubmitbutton = (Button) findviewbyid(r.id.submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id.firstname); } } You should remove the android:onclick attribute from the submitbutton in the XML file
86 Events - Implement EventListener public class HelloWorldActivity extends Activity implements OnClickListener public void oncreate(bundle savedinstancestate) { } super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button msubmitbutton = (Button) findviewbyid(r.id.submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id.firstname); msubmitbutton.setonclicklistener(this); public void onclick(view v) { }...
87 Events - Implement EventListener public class HelloWorldActivity extends Activity implements OnClickListener public void oncreate(bundle savedinstancestate) { } super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button msubmitbutton = (Button) findviewbyid(r.id.submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id.firstname); What if I remove this? msubmitbutton.setonclicklistener(this); Try it. public void onclick(view v) { }...
88 Events - Handling Events There are 3 ways to incorporate EventListeners: 1. Specify the name of the method to handle the event in XML. We just did this. 2. Have your Activity implement an EventListener 3. Create an anonymous implementation of the EventListener
89 Events - Anonymous Listener public class HelloWorldActivity extends public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button msubmitbutton = (Button) findviewbyid(r.id.submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id.firstname); } }
90 Events - Anonymous Listener public class HelloWorldActivity extends Activity{ public void oncreate(bundle savedinstancestate) { } super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button msubmitbutton = (Button) findviewbyid(r.id.submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id.firstname); Doesn't need to implement OnClickListener this time!
91 Events - Anonymous Listener public class HelloWorldActivity extends public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout. main); Button msubmitbutton = (Button) findviewbyid(r.id. submitbutton); EditText mfirstname = (EditText) findviewbyid(r.id. firstname); } } msubmitbutton.setonclicklistener( new OnClickListener() { public void onclick(view v) { /* submitbutton clicked */ } });
92 Events - Anonymous Listener A fast way to set the onclicklistener: after typing msubmitbutton. (including the dot) choose the setonclicklistener method from the list 1. in the parentheses, type new (including the whitespace) 2. press Ctrl+Spacebar 3. select View.OnClickListener from the list 4. You may have to press Ctrl + o to import any missing packages 5. add a semicolon at the end of the autogenerated code 6. add your code to the auto-generated methods
93 References Android Developers The Mobile Lab at Florida State University
Mobile Programming Lecture 3. Resources, Selection, Activities, Intents
Mobile Programming Lecture 3 Resources, Selection, Activities, Intents Lecture 2 Review What widget would you use to allow the user to enter a yes/no value a range of values from 1 to 100 What's the benefit
More informationHello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial
Hello World Lesson 1 This work is licensed This under work a Creative is is licensed Commons under a a Attribution-NonCommercial Creative 4.0 Commons International Attribution- License 1 NonCommercial
More informationANDROID APPS DEVELOPMENT FOR MOBILE GAME
ANDROID APPS DEVELOPMENT FOR MOBILE GAME Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Layout and Permission Present
More informationProgramming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna
Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Components of an Activity ViewGroup: definition
More informationANDROID USER INTERFACE
1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed
More informationAndroid App Development. Mr. Michaud ICE Programs Georgia Institute of Technology
Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based
More informationAndroid UI: Overview
1 Android UI: Overview An Activity is the front end component and it can contain screens. Android screens are composed of components or screen containers and components within the containers Screen containers
More informationCreating a User Interface
Creating a User Interface Developing for Android devices is a complicated process that requires precision to work with. Android runs on numerous devices from smart-phones to tablets. Instead of using a
More informationUser Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University
User Interface: Layout Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University http://twitter.com/krunapon Agenda User Interface Declaring Layout Common Layouts User Interface
More informationMobile Programming Lecture 1. Getting Started
Mobile Programming Lecture 1 Getting Started Today's Agenda About the Android Studio IDE Hello, World! Project Android Project Structure Introduction to Activities, Layouts, and Widgets Editing Files in
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Programming
More informationCS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming Emmanuel Agu Editting in Android Studio Recall: Editting Android Can edit apps in: Text View: edit XML directly Design
More informationCS371m - Mobile Computing. User Interface Basics
CS371m - Mobile Computing User Interface Basics Clicker Question Have you ever implemented a Graphical User Interface (GUI) as part of a program? A. Yes, in another class. B. Yes, at a job or internship.
More information(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1
Level 5: Baccalaureus in Computer Sciences CHAPTER 4: LAYOUTS AND VIEWS Dr. Sonia Saïd LAJMI PhD in Computer Sciences 1 Layout.xml 2 Computer Sciences & IT (girl Section) 1 Layout Requirements android:layout_width:
More informationMobile User Interfaces
Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00
More informationTextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input
1 UI Components 2 UI Components 3 A label is called a TextView. TextView TextViews are typically used to display a caption TextViews are not editable, therefore they take no input - - - - - - -
More informationLab 1 - Setting up the User s Profile UI
Lab 1 - Setting up the User s Profile UI Getting started This is the first in a series of labs that allow you to develop the MyRuns App. The goal of the app is to capture and display (using maps) walks
More informationEventually, you'll be returned to the AVD Manager. From there, you'll see your new device.
Let's get started! Start Studio We might have a bit of work to do here Create new project Let's give it a useful name Note the traditional convention for company/package names We don't need C++ support
More informationPraktikum Entwicklung Mediensysteme. Implementing a User Interface
Praktikum Entwicklung Mediensysteme Implementing a User Interface Outline Introduction Programmatic vs. XML Layout Common Layout Objects Hooking into a Screen Element Listening for UI Notifications Applying
More informationAndroid User Interface
Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 Android User Interface 2 Multi-Language Support 3 Summary Matthias Keil Android
More informationAndroid User Interface Android Smartphone Programming. Outline University of Freiburg
Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 2 Multi-Language Support 3 Summary Matthias Keil 20. Oktober 2014 2 / 19 From
More informationCS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples Emmanuel Agu Android UI Design in XML Recall: Files Hello World Android Project XML file used to design Android UI
More informationFragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment
FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each
More informationCS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu
CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming Emmanuel Agu Android Apps: Big Picture UI Design using XML UI design code (XML) separate from the program (Java) Why?
More informationLECTURE 08 UI AND EVENT HANDLING
MOBILE APPLICATION DEVELOPMENT LECTURE 08 UI AND EVENT HANDLING IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM User Interface User Interface The Android Widget Toolbox 1. TextView 2. EditText 3. Spinner
More informationProgramming with Android: Widgets and Events. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna
Programming with Android: Widgets and Events Luca Bedogni Dipartimento di Scienze dell Informazione Università di Bologna Outline What is a Widget? Widget: TextView and EditText Widget: Button and CompoundButton
More informationCS 234/334 Lab 1: Android Jump Start
CS 234/334 Lab 1: Android Jump Start Distributed: January 7, 2014 Due: Friday, January 10 or Monday, January 13 (in-person check off in Mobile Lab, Ry 167). No late assignments. Introduction The goal of
More informationGUI Widget. Lecture6
GUI Widget Lecture6 AnalogClock/Digital Clock Button CheckBox DatePicker EditText Gallery ImageView/Button MapView ProgressBar RadioButton Spinner TextView TimePicker WebView Android Widgets Designing
More informationProduced by. Mobile Application Development. Eamonn de Leastar
Mobile Application Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie A First
More informationCreate new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.
Hello World Lab Objectives: Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.xml What to Turn in: The lab evaluation
More informationGUI Design for Android Applications
GUI Design for Android Applications SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November
More informationTextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.
A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has
More informationCS378 -Mobile Computing. User Interface Basics
CS378 -Mobile Computing User Interface Basics User Interface Elements View Control ViewGroup Layout Widget (Compound Control) Many pre built Views Button, CheckBox, RadioButton TextView, EditText, ListView
More information04. Learn the basic widget. DKU-MUST Mobile ICT Education Center
04. Learn the basic widget DKU-MUST Mobile ICT Education Center Goal Understanding of the View and Inheritance of View. Learn how to use the default widget. Learn basic programming of the Android App.
More informationAndroid Beginners Workshop
Android Beginners Workshop at the M O B IL E M O N D AY m 2 d 2 D E V E L O P E R D A Y February, 23 th 2010 Sven Woltmann, AndroidPIT Sven Woltmann Studied Computer Science at the TU Ilmenau, 1994-1999
More informationCS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu Android UI Design Example GeoQuiz App Reference: Android Nerd Ranch, pgs 1 30 App presents
More informationListView Containers. Resources. Creating a ListView
ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a
More informationMobile Programming Lecture 4. Debugging
Mobile Programming Lecture 4 Debugging Lecture 2 Review How do you make the android:inputtype attribute of an EditText both textcapwords and textmultiline? Why should you use a @string resource for TextViews
More informationAndroid UI Development
Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding
More informationUsing Eclipse for Android Development
3 Using Eclipse for Android Development This chapter is an introduction to building a complete Android app. The chapter includes creating a new app project, exploring the components of an Android app,
More informationAndroid Apps Development for Mobile and Tablet Device (Level I) Lesson 2
Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control
More informationAndroid Programming (5 Days)
www.peaklearningllc.com Android Programming (5 Days) Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse tools. This Android
More informationA view is a widget that has an appearance on screen. A view derives from the base class android.view.view.
LAYOUTS Views and ViewGroups An activity contains Views and ViewGroups. A view is a widget that has an appearance on screen. A view derives from the base class android.view.view. One or more views can
More informationCS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu
CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu WebView Widget WebView Widget A View that displays web pages Can be used for creating your own web browser OR just display
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationES E 3 3 L a L b 5 Android development
ES3 Lab 5 Android development This Lab Create a simple Android interface Use XML interface layouts Access the filesystem Play media files Info about Android development can be found at http://developer.android.com/index.html
More information14.1 Overview of Android
14.1 Overview of Android - Blackberry smart phone appeared in 2003 First widely used mobile access to the Web - Smart phone market now dominated by Android, iphone, and Windows Phone - Tablets are now
More informationDeveloped and taught by well-known Contact author and developer. At public for details venues or onsite at your location.
2011 Marty Hall Android Programming Basics Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/
More informationFragments. Lecture 11
Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait
More informationConstraintLayouts in Android
B ConstraintLayouts in Android Constrained Layouts are a new addition to Android. These layouts are similar to Relative Layouts, in that all widgets are positioned with respect to other UI elements. However,
More informationFragments. Lecture 10
Fragments Lecture 10 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait
More informationThis lecture. The BrowserIntent Example (cont d)
This lecture 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 10: Working with the Web Browser Dr Dimitris C. Dracopoulos Android provides a full-featured web browser based on the Chromium open source
More informationLab 1: Getting Started With Android Programming
Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project
More informationIntroductory Android Development
Introductory Android Development 152-163 Notes Quick Links & Text References Introduction Pages Layout Concepts Pages Layout Types Pages 35 37 XML Overview Pages Common Attributes Layout Height & Width
More informationRequired Core Java for Android application development
Required Core Java for Android application development Introduction to Java Datatypes primitive data types non-primitive data types Variable declaration Operators Control flow statements Arrays and Enhanced
More informationMobile Computing Practice # 2c Android Applications - Interface
Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not
More informationHave a development environment in 256 or 255 Be familiar with the application lifecycle
Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in
More informationBuilding User Interface for Android Mobile Applications II
Building User Interface for Android Mobile Applications II Mobile App Development 1 MVC 2 MVC 1 MVC 2 MVC Android redraw View invalidate Controller tap, key pressed update Model MVC MVC in Android View
More informationCS260 Intro to Java & Android 05.Android UI(Part I)
CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2015 Winter 2015 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base
More informationUser Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.
User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android
More informationCS260 Intro to Java & Android 05.Android UI(Part I)
CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2018 Winter 2018 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base
More informationUniversity of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World
University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World Before you do anything read all of the following red paragraph! For this lab you
More informationCS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples. Emmanuel Agu
CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples Emmanuel Agu Resources Android Resources Resources? Images, strings, dimensions, layout files, menus, etc that your
More informationMobile Application Development Android
Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications
More informationAndroid development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.
Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code
More informationCS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu Android UI Tour Home Screen First screen after unlocking phone or hitting home button Includes favorites tray
More informationLecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming
University of Babylon College of Information Technology Department of Information Networks Mobile Fundamentals and Programming Lecture 7: Data Persistence : shared preferences Lecturer : Ali Kadhim Al-Bermani
More informationStanislav Rost CSAIL, MIT
Session 2: Lifecycles, GUI Stanislav Rost CSAIL, MIT The Plan 1 Activity lifecycle Service lifecycle 2 Selected GUI elements UI Layouts 3 Hands on assignment: RoboChat Application GUI Design Birth, death,
More informationCS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu Students: Please Introduce Yourselves! Name Status: grad/undergrad, year Relevant background: e.g. coal miner
More informationMC Android Programming
MC1921 - Android Programming Duration: 5 days Course Price: $3,395 Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse
More informationMAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.
MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified
More informationIntroduction To Android
Introduction To Android Mobile Technologies Symbian OS ios BlackBerry OS Windows Android Introduction to Android Android is an operating system for mobile devices such as smart phones and tablet computers.
More informationMobile Programming Lecture 5. Composite Views, Activities, Intents and Filters
Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or
More informationProgramming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: Introduction Layouts Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Views: outline Main difference between a Drawable and
More informationOverview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners
Layouts and Views http://developer.android.com/guide/topics/ui/declaring-layout.html http://developer.android.com/reference/android/view/view.html Repo: https://github.com/karlmorris/viewsandlayouts Overview
More informationUI (User Interface) overview Supporting Multiple Screens Touch events and listeners
http://www.android.com/ UI (User Interface) overview Supporting Multiple Screens Touch events and listeners User Interface Layout The Android user interface (UI) consists of screen views (one or more viewgroups
More informationProgramming Android UI. J. Serrat Software Design December 2017
Programming Android UI J. Serrat Software Design December 2017 Preliminaries : Goals Introduce basic programming Android concepts Examine code for some simple examples Limited to those relevant for the
More informationCOMP4521 EMBEDDED SYSTEMS SOFTWARE
COMP4521 EMBEDDED SYSTEMS SOFTWARE LAB 1: DEVELOPING SIMPLE APPLICATIONS FOR ANDROID INTRODUCTION Android is a mobile platform/os that uses a modified version of the Linux kernel. It was initially developed
More informationMobile and Ubiquitous Computing: Android Programming (part 3)
Mobile and Ubiquitous Computing: Android Programming (part 3) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Based on Programming Handheld Systems, Adam Porter, University
More informationFigure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.
44 CHAPTER 2 Android s development environment Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. TIP You ll want the package name of your applications to be unique
More informationAndroid Programming Lecture 2 9/7/2011
Android Programming Lecture 2 9/7/2011 Creating a first app 1. Create a new Android project (a collection of source code and resources for the app) from the Eclipse file menu 2. Choose a project name (can
More informationMOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?
MOBILE COMPUTING CSE 40814/60814 Spring 2018 How many of you have implemented a command-line user interface? How many of you have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework
More informationMobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences Agenda Dialogs Menus SharedPreferences Android Application Components 1. Activity 2. Broadcast Receiver 3. Content Provider 4. Service
More informationWhen programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:
ETSN05, Fall 2017, Version 1.0 Software Development of Large Systems Lab 2 preparations Read through this document carefully. In order to pass lab 2, you will need to understand the topics presented in
More informationMVC Apps Basic Widget Lifecycle Logging Debugging Dialogs
Overview MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Lecture: MVC Model View Controller What is an App? Android Activity Lifecycle Android Debugging Fixing Rotations & Landscape Layouts Localization
More informationActivities and Fragments
Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com
More informationINTRODUCTION TO ANDROID
INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android
More informationProduced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology
Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -
More informationO X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game
Tic-Tac-Toe 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Dr Dimitris C. Dracopoulos O X X X O O X O X The Ultimate Tic-Tac-Toe: Rules of the Game Dimitris C. Dracopoulos
More informationAndroid Basics. Android UI Architecture. Android UI 1
Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à
More informationAndroid Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)
Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs
More informationAdapting to Data. Before we get to the fun stuff... Initial setup
Adapting to Data So far, we've mostly been sticking with a recurring theme: visual elements are tied to XML-defined resources, not programmatic creation or management. But that won't always be the case.
More informationSolving an Android Threading Problem
Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know
More informationEMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches
EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed
More informationEECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)
EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not
More informationApplied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)
Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application
More informationLab 3. Accessing GSM Functions on an Android Smartphone
Lab 3 Accessing GSM Functions on an Android Smartphone 1 Lab Overview 1.1 Goals The objective of this practical exercise is to create an application for a smartphone with the Android mobile operating system,
More informationMobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09
Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Hello, today we will create another application called a math quiz. This
More informationWireless Vehicle Bus Adapter (WVA) Android Library Tutorial
Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Revision history 90001431-13 Revision Date Description A October 2014 Original release. B October 2017 Rebranded the document. Edited the document.
More information