Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento
|
|
- Cora Barnett
- 6 years ago
- Views:
Transcription
1 Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento
2 Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void onclick( v) { Log.d("TRACE", "Button has been clicked "); Anonymous ); Inner Class In Swing it was JButton button= button.addactionlistener (new ActionListener() { public void actionperformed(actionevent e) { 2 ); ;
3 Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void onclick( v) { Log.d("TRACE", "Button has been clicked "); ); The event target Is passed MAIN DIFFERENCE 3 In Swing it was JButton button= button.addactionlistener (new ActionListener() { public void actionperformed(actionevent e) { ; ); The event is passed
4 An alternative The various classes expose several public callback methods that are useful for UI events. These methods are called by the Android framework when the respective action occurs on that object. For instance, when a (such as a Button) is touched, the ontouchevent() method is called on that object. However, in order to intercept this, you must extend the class and override the method. 4
5 Extending Button to deal with events Class MyButton extends Button { public boolean ontouchevent(motionevent event) { int eventaction = event.getaction(); switch (eventaction) { case MotionEvent.ACTION_DOWN: // finger touches the screen ; break; case MotionEvent.ACTION_MOVE: // finger moves on the screen ; break; 5 case MotionEvent.ACTION_UP: // finger leaves the screen ; break; // tell the system that we handled the event and no further processing is needed return true;
6 6 SimpleClick
7 Let s recap how to build an app 1) Define the Activity Resources 1) Choose a Layout 2) Add the components via XML 3) Define the strings 2) Code the activity 3) Add info to the Manifest (if needed) 7
8 UML Diagram Activity Layout Text Button 2 Text settitle() String String String 8
9 9 Let s define the aspect of layout1 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= " android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Text android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button1_label" /> <Text android:id="@+id/tf1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/output" /> </LinearLayout>
10 Let s define the strings <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">this is Activity A1</string> <string name="app_name">simpleclick</string> <string name="button1_label">click me!</string> <string name="output">no results yet...</string> </resources> 10
11 SimpleClick A1 package it.unitn.science.latemar; import android.app.activity; import android.os.bundle; import android.view.; import android.widget.button; import android.widget.text; public class A1 extends Activity { int nclicks=0; protected void oncreate(bundle b) { super.oncreate(b); setcontent(r.layout.layout1); final Button button = (Button) findbyid(r.id.button1); final Text tf = (Text) findbyid(r.id.tf1); 11 button.setonclicklistener(new.onclicklistener() { public void onclick( v) { tf.settext("clicks :"+(++nclicks)); );
12 Calling Activities: Explicit Intents Marco Ronchetti Università degli Studi di Trento
13 startactivity(intent x) startactivity(intent x) (method of class Activity) starts a new activity, which will be placed at the top of the activity stack. takes a single argument which describes the activity to be executed. 13 An intent is an abstract description of an operation to be performed.
14 14 A simple example: A1 calls A2
15 Explicit Intents We will use the basic mode: Explicit starting an activity Explicit Intents specify the exact class to be run. Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application. 15
16 Intent The context of the sender The class to be activated new Intent(Context c, Class c); Remember that a Context is a wrapper for global information about an application environment, and that Activity subclasses Context 16 Equivalent form: Intent i=new Intent(); i.setclass(context c1, Class c2);
17 Let s define the aspect of layout1 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= " android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Text android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/activity1hellostring" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button1label" /> 17 </LinearLayout>
18 Let s define the strings <?xml version="1.0" encoding="utf-8"?> <resources> <string name="activity2hellostring">this is Activity TWO</string> <string name="app_name">buttonactivatedactions</string> <string name="activity1hellostring">this is Activity ONE</string> <string name="button1label">call Activity TWO</string> <string name="button2label">call Activity ONE</string> 18 </resources>
19 A1 and A2 package it.unitn.science.latemar; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.; import android.widget.button; public class A1 extends Activity { protected void oncreate(bundle icicle) { super.oncreate(icicle); package it.unitn.science.latemar; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.; import android.widget.button; public class A2 extends Activity { protected void oncreate(bundle icicle) { super.oncreate(icicle); setcontent(r.layout.layout1); final Button button = (Button) findbyid( R.id.button1); button.setonclicklistener( new.onclicklistener() { public void onclick( v) { Intent intent = new Intent(A1.this, A2.class); startactivity(intent); ); 19 Anonymous Inner Class setcontent(r.layout.layout2); final Button button = (Button) findbyid( R.id.button2); button.setonclicklistener( new.onclicklistener() { public void onclick( v) { Intent intent = new Intent(A2.this, A1.class); startactivity(intent); );
20 A1.this? What s that? button.setonclicklistener(new.onclicklistener() { public void onclick( v) { Intent intent = new Intent(A1.this, A2.class); startactivity(intent); ); final Activity me=this; button.setonclicklistener(new.onclicklistener() { ); public void onclick( v) { Intent intent = new Intent(me, A2.class); startactivity(intent); 20 final Intent intent = new Intent(this, A2.class); button.setonclicklistener(new.onclicklistener() { ); public void onclick( v) { startactivity(intent);
21 Let s declare A2 in the manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="it.unitn.science.latemar" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="13" /> 21 <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="a1" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="a2"></activity> </application> </manifest>
22 How many instances? Marco Ronchetti Università degli Studi di Trento
23 How many instances? BACK BACK BACK BACK 23
24 public class A1 extends Activity { static int instances = 0; Text tf = null; protected void oncreate(bundle icicle) { super.oncreate(icicle); instances++; setcontent(r.layout.layout1); tf = (Text) findbyid(r.id.instancecount); final Button button = (Button) findbyid(r.id.button1); final Intent intent = new Intent(this, A2.class); button.setonclicklistener(new.onclicklistener() { public void onclick( v) { 24 startactivity(intent); ); The code protected void ondestroy() { super.ondestroy(); instances--; protected void onresume() { super.onresume(); if (tf!= null) tf.settext("instance count: A1 = " + A1.instances+" - count A2 = " + A2.instances);
25 Activity lifecycle States (colored), and Callbacks (gray) 25
26 The xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Text android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Text android:layout_width="fill_parent" android:layout_height="wrap_content" /> 26 </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <resources> <string name="activity2hellostring"> This is Activity TWO</string> <string name="app_name"> ButtonActivatedActions</string> <string name="activity1hellostring"> This is Activity ONE</string> <string name="button1label"> Call Activity TWO</string> <string name="button2label"> Call Activity ONE</string> <string name="instancecount"> Instance count: field not initialized</string> <string name="instancecount2"> Instance count: field not initialized</string> </resources>
27 Minimizing instances protected void oncreate(bundle icicle) { super.oncreate(icicle); instances++; setcontent(r.layout.layout2); tf2 = (Text) findbyid(r.id.instancecount2); final Button button = (Button) findbyid(r.id.button2); final Intent intent = new Intent(this, A1.class); intent.setflags(intent.flag_activity_clear_top); button.setonclicklistener(new.onclicklistener() { ); public void onclick( v) { startactivity(intent); 27 BACK
28 FLAG_ACTIVITY_CLEAR_TOP senza FLAG_ACTIVITY_CLEAR_TOP A B C D B con FLAG_ACTIVITY_CLEAR_TOP (C e D vengono distrutte) 28
29 For details see FLAGS 29
30 Calling Activities with return values: startactivityforresults Marco Ronchetti Università degli Studi di Trento
31 31 Returning data
32 Calling activity package it.unitn.science.latemar; import public class CallingActivity extends Activity { int requestcode=100; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontent(r.layout.layout1); final Intent i = new Intent(this,CalledActivity.class); final Button button = (Button) findbyid(r.id.invokebutton); button.setonclicklistener(new.onclicklistener() { public void onclick( v) { startactivityforresult(i, requestcode); ); 32 protected void onactivityresult(int requestcode, int resultcode, Intent data) { super.onactivityresult(requestcode, resultcode, data); final Text tf = (Text) findbyid(r.id.output); if (resultcode==1){ tf.settext(data.getstringextra("payload")); else{ tf.settext("action cancelled"); The name should be qualified with the package
33 33 Called activity public class CalledActivity extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontent(r.layout.layout2); final Intent in = new Intent(); final Button button = (Button) findbyid(r.id.okbutton); final EditText tf = (EditText) findbyid(r.id.edittext1); button.setonclicklistener(new.onclicklistener() { public void onclick( v) { setresult(1,in); in.putextra("payload", tf.gettext().tostring()); finish(); ); final Button button_c = (Button) findbyid(r.id.cancelbutton); button_c.setonclicklistener(new.onclicklistener() { public void onclick( v) { setresult(0,in); finish(); ); package it.unitn.science.latemar; import The name should be qualified with the package
34 Remember to register the Activity! 34 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="it.unitn.science.latemar" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="13" /> <application > <activity android:name=".callingactivity" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="calledactivity"></activity> </application> </manifest>
35 Extras setextra(string name, #TYPE# payload) where #TYPE# = one of Primitive data types String or various types of serializable objects get Extra(String name) where is the name of the data types available in getters removeextra(string name) 35 replaceextra completely replace the Extras
36 Basic UI elements: s and Layouts, a deeper insight Marco Ronchetti Università degli Studi di Trento
37 Widgets examples 37 See
38 38 Layout examples
39 Defining layouts in XML Each layout file must contain exactly one root element, which must be a or Group object. Once you've defined the root element, you can add additional layout objects or widgets as child elements to gradually build a hierarchy that defines your layout. 39
40 A view of the s Group Absolute Layout Stub Analog Clock Frame Layout Surface Keyboard Grid Layout Texture Space Linear Layout Progress Bar Image Relative Layout Text Digital Clock Edit Text Button 40 Scroll Calendar And several more TimePicker Toggle Button Media Controller Switch Radio Button Compound Button Check Box
41 invisible, zero-sized that can be used to lazily inflate layout resources at A view of the s surface runtime. Group Absolute Layout Stub Analog Clock analogic clock with two hands for hours and minutes Frame Layout a dedicated drawing Surface Keyboard Grid Layout a keyboard used to display a content stream Texture Space used to create gaps Linear between components Layout a progress bar Progress Bar Image Displays an Relative arbitrary image, such Layout as an icon. Text Displays text to the user and optionally allows them to edit it. Digital Clock Edit Text Button 41 Scroll Calendar And several more TimePicker Toggle Button Media Controller Switch Radio Button Compound Button Check Box
42 42 A view of the s PLEASE READ THIS: Group Absolute Layout Scroll Stub Analog Clock Frame Layout Calendar two-state toggle switch widget that can select between two options. And several more Displays checked/ unchecked states as a button Surface Keyboard Grid Layout TimePicker Toggle Button Texture Space Linear Layout Media Controller Switch Progress Bar Image An editable Text Relative a pushbutton Layout A button with two states Radio Button Text Like AnalogClock, but digital. Digital Clock Edit Text Button Compound Button Check Box
43 Android vs. Swing architectures Group Layout Layout Component Container 43
44 A view of the s block out an area on the screen Group to display a single item Absolute Layout A layout that lets you specify exact Scroll locations (x/y coordinates) of its children 44 DEPRECATED! Stub Analog Clock Frame Layout Calendar And several more Surface Keyboard Grid Layout places its children in a rectangular grid. TimePicker Toggle Button Texture Linear Layout Media Controller Switch Progress Bar arranges its children in a single column or Space a single row. Image Relative Layout Radio Button Text the positions of the children can be described in relation to each other or to the parent.. Digital Clock Edit Text Button Compound Button Check Box
45 A view of the s Group container for a view Absolute hierarchy that Layout can be scrolled Stub calendar widget for displaying and selecting dates Analog Clock Frame Layout Surface Keyboard A view for selecting the time of day, Grid Layout Texture Space A view containing controls for a MediaPlayer Linear Layout Progress Bar Image Relative Layout Text Digital Clock Edit Text Button 45 Scroll Calendar And several more TimePicker Toggle Button Media Controller Switch Radio Button Compound Button Check Box
46 Layout examples See several examples in We quickly discuss some of them here. 46
47 Layout properties - horizontal <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="invia" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content /> <Button android:text="cancella" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> 47
48 Layout properties - margin 48 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="invia" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content android:layout_marginleft="25px" android:layout_marginright="25px"/> <Button android:text="cancella" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
49 Layout properties fill_parent <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation= horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="invia" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <Button android:text="cancella" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> 49
50 Layout properties weight 50 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation= horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="invia" android:layout_width="fill_parent" android:layout_height="wrap_content android:layout_weight="1"/> <Button android:text="cancella" android:layout_width="fill_parent" android:layout_height="wrap_content android:layout_weight= 2"/> </LinearLayout>
51 Layout properties - vertical <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="invia" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:text="cancella" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> 51
52 Basic operations on Set properties: e.g. setting the text of a Text (settext()). Available properties, getters and setters vary among the different subclasses of views. Properties can also be set in the XML layout files. Set focus: Focus is moved in response to user input. To force focus to a specific view, call requestfocus(). Set up listeners: e.g. setonfocuschangelistener (android.view..onfocuschangelistener). subclasses offer specialized listeners. 52 Set visibility: You can hide or show views using setvisibility(int). (One of VISIBLE, INVISIBLE, or GONE.) Invisible, but it still takes up space for layout purposes Invisible, and it takes no space for layout purposes
53 Size and location of a Although there are setters for posizition and size, theyr values are usually controlled (and overwritten) by the Layout. getleft(), gettop() : get the coordinates of the upper left vertex. getmeasuredheight() e getmeasuredwidth() return the preferred dimensions 53 getwidth() e getheight() return the actual dimensions.
54 Custom views To implement a custom view, you will usually begin overriding for some of the standard methods that the framework calls on all views (at least ondraw()). For more details, see view/.html 54
Getting started: Hello Android. Marco Ronchetti Università degli Studi di Trento
Getting started: Hello Android Marco Ronchetti Università degli Studi di Trento HelloAndroid package com.example.helloandroid; import android.app.activity; import android.os.bundle; 2 public class HelloAndroid
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 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 informationApplications. Marco Ronchetti Università degli Studi di Trento
Applications Marco Ronchetti Università degli Studi di Trento Android Applications An Android application typically consists of one or more related, loosely bound activities for the user to interact with.
More informationGetting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento
Getting started: Installing IDE and SDK Marco Ronchetti Università degli Studi di Trento Alternative: Android Studio http://developer.android.com/develop/index.html 2 Tools behind the scenes dx allows
More informationSecurity model. Marco Ronchetti Università degli Studi di Trento
Security model Marco Ronchetti Università degli Studi di Trento Security model 2 Android OS is a multi-user Linux in which each application is a different user. By default, the system assigns each application
More informationVienos veiklos būsena. Theory
Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is
More informationManifest.xml. Activity.java
Dr.K.Somasundaram Ph.D Professor Department of Computer Science and Applications Gandhigram Rural Institute, Gandhigram, Tamil Nadu-624302, India ka.somasundaram@gmail.com Manifest.xml
More informationIslamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Mobile Computing ECOM 5341 By Eng. Wafaa Audah July 2013 1 Launch activitits, implicit intents, data passing & start activity
More informationLifeStreet Media Android Publisher SDK Integration Guide
LifeStreet Media Android Publisher SDK Integration Guide Version 1.12.0 Copyright 2015 Lifestreet Corporation Contents Introduction... 3 Downloading the SDK... 3 Choose type of SDK... 3 Adding the LSM
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 informationAndroid Basics. - Bhaumik Shukla Android Application STEALTH FLASH
Android Basics - Bhaumik Shukla Android Application Developer @ STEALTH FLASH Introduction to Android Android is a software stack for mobile devices that includes an operating system, middleware and key
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 informationAndroid. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license
Android Android Mobile operating system developed by Google A complete stack OS, framework A rich set of applications Email, calendar, browser, maps, text messaging, contacts, camera, dialer, music player,
More informationGetting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering
Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework
More informationLearn about Android Content Providers and SQLite
Tampa Bay Android Developers Group Learn about Android Content Providers and SQLite Scott A. Thisse March 20, 2012 Learn about Android Content Providers and SQLite What are they? How are they defined?
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 informationAction Bar. (c) 2010 Haim Michael. All Rights Reserv ed.
Action Bar Introduction The Action Bar is a widget that is shown on top of the screen. It includes the application logo on its left side together with items available from the options menu on the right.
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 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 informationAndroid Services. Victor Matos Cleveland State University. Services
22 Android Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 22. Android Android A Service is an application component that runs in
More informationAndroid Workshop: Model View Controller ( MVC):
Android Workshop: Android Details: Android is framework that provides java programmers the ability to control different aspects of smart devices. This interaction happens through the Android SDK (Software
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 information8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?
MOBILE COMPUTING CSE 40814/60814 Fall 2015 How many of you have implemented a command-line user interface? 1 How many of you have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework
More informationEMBEDDED SYSTEMS PROGRAMMING Application Basics
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there
More informationReal-Time Embedded Systems
Real-Time Embedded Systems DT8025, Fall 2016 http://goo.gl/azfc9l Lecture 8 Masoumeh Taromirad m.taromirad@hh.se Center for Research on Embedded Systems School of Information Technology 1 / 51 Smart phones
More informationIntents. Your first app assignment
Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work
More informationNotification mechanism
Notification mechanism Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Portions of this page are reproduced from work created
More informationSimple Currency Converter
Simple Currency Converter Implementing a simple currency converter: USD Euro Colon (CR) Note. Naive implementation using the rates 1 Costa Rican Colon = 0.001736 U.S. dollars 1 Euro = 1.39900 U.S. dollars
More informationUNDERSTANDING ACTIVITIES
Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device
More informationAndroid Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]
s@lm@n Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ] Android AND-401 : Practice Test Question No : 1 Which of the following is required to allow the Android
More informationActivities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities
Activities https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Overview What is an Activity Starting and stopping activities The Back Stack
More informationDiving into Android. By Jeroen Tietema. Jeroen Tietema,
Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com
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 informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationUnderstand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good
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 informationApp Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out
App Development for Smart Devices CS 495/595 - Fall 2013 Lec #7: Audio, Video & Telephony Try It Out Tamer Nadeem Dept. of Computer Science Trt It Out Example - SoundPool Example - VideoView Page 2 Fall
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are
More informationServices. Marco Ronchetti Università degli Studi di Trento
1 Services Marco Ronchetti Università degli Studi di Trento Service An application component that can perform longrunning operations in the background and does not provide a user interface. So, what s
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 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 informationAndroid Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs,
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 informationServices. Marco Ronchetti Università degli Studi di Trento
1 Services Marco Ronchetti Università degli Studi di Trento Service An application component that can perform longrunning operations in the background and does not provide a user interface. So, what s
More informationCreate Parent Activity and pass its information to Child Activity using Intents.
Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;
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 informationCreated By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography
Created By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography 1. Thread Summery 2. Thread creation 3. App Diagram and information flow 4. General flow of Diffie-Hellman 5. Steps of
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should
More informationOur First Android Application
Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,
More informationAndroid Application Model I
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);
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 informationMAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.
MAD ASSIGNMENT NO 3 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MainActivity.java File package com.example.tutorialspoint; import android.manifest;
More informationAndroid HelloWorld - Example. Tushar B. Kute,
Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it
More informationAndroid Application Development. By : Shibaji Debnath
Android Application Development By : Shibaji Debnath About Me I have over 10 years experience in IT Industry. I have started my career as Java Software Developer. I worked in various multinational company.
More information<uses-permission android:name="android.permission.internet"/>
Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework
More informationProgramming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: Introduction Layouts Luca Bedogni Dipartimento di Informatica: Scienza e Ingegneria Uniersità di Bologna Views: outline Main difference between a Drawable and a View is reaction
More informationMultiple Activities. Many apps have multiple activities
Intents Lecture 7 Multiple Activities Many apps have multiple activities An activity A can launch another activity B in response to an event The activity A can pass data to B The second activity B can
More informationSoftware Practice 3 Before we start Today s lecture Today s Task Team organization
1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R
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 information10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics
Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic
More informationAdapter.
1 Adapter An Adapter object acts as a bridge between an AdapterView and the underlying data for that view The Adapter provides access to the data items The Adapter is also responsible for making a View
More informationThread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.
1 Thread A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main
More informationCS 193A. Multiple Activities and Intents
CS 193A Multiple Activities and Intents This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Multiple
More informationBasic GUI elements - exercises
Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add
More informationMobile Development Lecture 8: Intents and Animation
Mobile Development Lecture 8: Intents and Animation Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com 1. Multiple Activities Intents Multiple Activities Many apps have multiple activities.
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 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 Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted
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 informationProgramming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna
Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android for Tablets: A Case Study Android for Tablets:
More informationComputer Science E-76 Building Mobile Applications
Computer Science E-76 Building Mobile Applications Lecture 3: [Android] The SDK, Activities, and Views February 13, 2012 Dan Armendariz danallan@mit.edu 1 http://developer.android.com Android SDK and NDK
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationandroid:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"
Parametrų keitimas veikiančioje aplikacijoje Let s create a project: Project name: P0181_DynamicLayout3 Build Target: Android 2.3.3 Application name: DynamicLayout3 Package name: ru.startandroid.develop.dynamiclayout3
More informationAgenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen
Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing
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 informationelse if(rb2.ischecked()) {
Problem :Toy Calculator Description:Please design an Android application that contains 2 activities: cal_main and cal_result. The following figure is a suggested layout for the cal_main activity. For the
More informationArrays of Buttons. Inside Android
Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.
More informationMobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.
Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New
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 informationProgramming of Mobile Services, Spring 2012
Programming of Mobile Services, Spring 2012 HI1017 Lecturer: Anders Lindström, anders.lindstrom@sth.kth.se Lecture 6 Today s topics Android graphics - Views, Canvas, Drawables, Paint - Double buffering,
More informationMODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING
This document can be downloaded from www.chetanahegde.in with most recent updates. 1 MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING Syllabus: What is Android? Obtaining the required tools, Anatomy
More informationGraphical User Interfaces
Graphical User Interfaces Some suggestions Avoid displaying too many things Well-known anti-patterns Display useful content on your start screen Use action bars to provide consistent navigation Keep your
More informationA Crash Course to Android Mobile Platform
Enterprise Application Development using J2EE Shmulik London Lecture #2 A Crash Course to Android Mobile Platform Enterprise Application Development Using J2EE / Shmulik London 2004 Interdisciplinary Center
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 informationLECTURE NOTES OF APPLICATION ACTIVITIES
Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The
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 informationApp Development for Smart Devices. Lec #18: Advanced Topics
App Development for Smart Devices CS 495/595 - Fall 2011 Lec #18: Advanced Topics Tamer Nadeem Dept. of Computer Science Objective Web Browsing Android Animation Android Backup Presentation - Developing
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 informationTablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time
Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application
More informationStarting Another Activity Preferences
Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the
More informationAndroid Application Development
Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited
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 informationAgenda. The Android GUI Framework Introduction Anatomy A real word example Life cycle Findings
The Android GUI Framework Java User Group Switzerland May 2008 Markus Pilz mp@greenliff.com Peter Wlodarczak pw@greenliff.com Agenda 1. 1. Introduction 2. 2. Anatomy 3. 3. A real word example 4. 4. Life
More informationTerms: MediaPlayer, VideoView, MediaController,
Terms: MediaPlayer, VideoView, MediaController, Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283
More information1 카메라 1.1 제어절차 1.2 관련주요메서드 1.3 제작철차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다.
1 카메라 1.1 제어절차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다. 1.2 관련주요메서드 setpreviewdisplay() : startpreview() : stoppreview(); onpicturetaken() : 사진을찍을때자동으로호출되며캡처한이미지가전달됨 1.3 제작철차 Step 1 프로젝트를생성한후매니페스트에퍼미션들을설정한다.
More informationMobila applikationer och trådlösa nät, HI1033, HT2012
Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationTopics of Discussion
Reference CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing Fragments, ActionBar and Menus Part 3 of 5 Android Programming Concepts, by Trish Cornez and Richard Cornez, pubslihed by Jones
More informationBasic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento
1 Basic UI elements: Defining Activity UI in the code Marco Ronchetti Università degli Studi di Trento UI Programmatically public class UIThroughCode extends Activity { LinearLayout llayout; TextView tview;
More information