Android User Interface Android Smartphone Programming. Outline University of Freiburg

Similar documents
Android User Interface

This lecture. The BrowserIntent Example (cont d)

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Mobile Application Development Android

Creating a User Interface

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

INTENTS android.content.intent

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Lab 3. Accessing GSM Functions on an Android Smartphone

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view.

Mobile User Interfaces

Android Locations. Android Smartphone Programming

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

The drawable/tile empty.xml file

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

The Suggest Example layout (cont ed)

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

Android Basics. Android UI Architecture. Android UI 1

14.1 Overview of Android

CS 234/334 Lab 1: Android Jump Start

Gauthier Picard. Ecole Nationale Supérieure des Mines

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

ListView Containers. Resources. Creating a ListView

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

Android Beginners Workshop

Android Application Development 101. Jason Chen Google I/O 2008

Programming with Android: System Architecture. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Android User Interface Overview. Most of the material in this sec7on comes from h8p://developer.android.com/guide/topics/ui/index.

Mobile and Ubiquitous Computing: Android Programming (part 3)

Embedded Systems Programming - PA8001

MOBILE CLIENT FOR ONLINE DICTIONARY. Constantin Lucian ALDEA 1. Abstract

FRAGMENTS.

8Messaging SMS MESSAGING.

Introduction To Android

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

ES E 3 3 L a L b 5 Android development

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

Android Application Development

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Mobila applikationer och trådlösa nät, HI1033, HT2012

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

Exercise 1: First Android App

Using Eclipse for Android Development

Android UI: Overview

Using Intents to Launch Activities

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)

XML for Android Developers. partially adapted from XML Tutorial by W3Schools

Eventually, you'll be returned to the AVD Manager. From there, you'll see your new device.

Stanislav Rost CSAIL, MIT

Programming Android UI. J. Serrat Software Design December 2017

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Creating a Custom ListView

CS378 -Mobile Computing. User Interface Basics

Hybrid Apps Combining HTML5 + JAVASCRIPT + ANDROID

ListView (link) An ordered collection of selectable choices. key attributes in XML:

Introduction to Android Development

Android Programming Lecture 2 9/7/2011

CMSC 436 Lab 10. App Widgets and Supporting Different Devices

Programming with Android: Widgets and Events. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Intents & Intent Filters. codeandroid.org

CS434/534: Topics in Networked (Networking) Systems

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

Useful tools for an effcient development of an Android App - The Android SDK

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

Activities and Fragments

CS260 Intro to Java & Android 05.Android UI(Part I)

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

Lab 1 - Setting up the User s Profile UI

CS260 Intro to Java & Android 05.Android UI(Part I)

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

CMSC436: Fall 2013 Week 3 Lab

Building User Interface for Android Mobile Applications II

Fragments. Lecture 10

Android Programming (5 Days)

App Development for Android. Prabhaker Matet

Graphical User Interfaces

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Introducing the Android Menu System

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Android Services. Victor Matos Cleveland State University. Services

SQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite

The World of Android Development

Mobila applikationer och trådlösa nät, HI1033, HT2013

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Embedded Systems Programming - PA8001

ANDROID APP DEVELOPMENT

GUI Widget. Lecture6

Transcription:

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 activity to widgets Activity Application component that provides a screen [1]. User interface of an activity is build using View and ViewGroup objects [5]. View Basis unit for user interface, base for subclasses called widgets. ViewGroup Base for subclasses called layouts. Matthias Keil 20. Oktober 2014 3 / 19

View Hierarchy Android View Hierarchy containing ViewGroup objects as nodes and View objects as leafs. Matthias Keil 20. Oktober 2014 4 / 19 Layout Can be defined in an XML layout file [7]. Similar to HTML layout development. Each element is a View or ViewGroup object or a subclass of these. ViewGroup objects contain more Views or ViewGroup objects. Matthias Keil 20. Oktober 2014 5 / 19 Example XML layout 1 <? xml version=" 1.0 " encoding="utf -8"?> 2 < LinearLayout xmlns:android =" http: // schemas. android.com /apk /res / android " 3 android:layout_width =" fill_parent " 4 android:layout_height =" fill_parent " 5 android:orientation =" vertical " > 6 < TextView android:id ="@+id/ text " 7 android:layout_width =" wrap_content " 8 android:layout_height =" wrap_content " 9 android:text=" Hello, I am a TextView " /> 10 <Button android:id ="@+id/ button " 11 android:layout_width =" wrap_content " 12 android:layout_height =" wrap_content " 13 android:text=" Hello, I am a Button " /> 14 </ LinearLayout > Matthias Keil 20. Oktober 2014 6 / 19

Widget Subclass of View. Serves as interaction interface with user. Many fully implemented widges available. Examples: Button, Checkbox, EditText and many more. Advanced Example WebView: Displays web pages and can use JavaScript [6]. Own implementation enables full customization of behavior. Matthias Keil 20. Oktober 2014 7 / 19 Input Events Many ways to intercept events from user interaction. Approach for user interface events: Capture events from View objects the user interacts with [2]. Two ways of implementation: Overwrite existing callback method. Define own event listener. Mostly used: Defining event listeners. Matthias Keil 20. Oktober 2014 8 / 19 Example: Overwriting Callback Method 1 public class MyActivity extends Activity { 2... 3 @Override 4 public boolean onkeydown ( int keycode, KeyEvent event ) { 5 // Do something. 6 } 7 } Matthias Keil 20. Oktober 2014 9 / 19

Example: Defining own Event Listener 1 public class MyActivity extends Activity { 2 private OnClickListener mylistener = new OnClickListener () { 3 public void onclick ( View v) { 4 // Do something. 5 } 6 }; 7 8 public void oncreate ( Bundle state ) { 9... 10 Button button = ( Button ) findviewbyid (R.id. mybutton ); 11 button. setonclicklistener ( mylistener ); 12... 13 } 14 } Matthias Keil 20. Oktober 2014 10 / 19 Intents and Broadcast Receivers Intent Message to communicate between components. [3]. Can connect components in the same or in different applications. Starts activities, background processes or notifies broadcast receivers. Broadcast Receiver Can be registered to receive certain intents. Example: Intent sent from system indicates incoming call and application stops playing music. Matthias Keil 20. Oktober 2014 11 / 19 Example: Intent to call telephone number Intent starts activity by specifying what action should be performed. Note: Activity only implicitly given though action. 1 Intent intent = new Intent ( Intent. ACTION_DIAL, Uri. parse ("tel :5905-5635 "); 2 startactivity ( intent ); Matthias Keil 20. Oktober 2014 12 / 19

Example: Broadcast receiver to react to phone calls Step 1: Create broadcast receiver as a new class. 1 public class MyPhoneReceiver extends BroadcastReceiver { 2 @Override 3 public void onreceive ( Context context, Intent intent ) { 4 // Do something. 5 } 6 } Matthias Keil 20. Oktober 2014 13 / 19 Example: Broadcast receiver to react to phone calls Step 2: Extend AndroidManifest.xml to register broadcast receiver to intents. 1 < application... > 2 < receiver android:name =" MyPhoneReceiver " > 3 <intent - filter> 4 < action android:name =" android. intent. action. PHONE_STATE " > 5 </ action > 6 </intent - filter> 7 </ receiver > 8 </ application > Matthias Keil 20. Oktober 2014 14 / 19 Multi-Language Support Overview Done though localization: Switch language according to locale settings of the device [4]. Helps reaching more users. Easy though separation of string resources and application code. Refer to string names in code and define strings in resource files. Matthias Keil 20. Oktober 2014 15 / 19

Multi-Language Support Resources Default resources in res/values/strings.xml provides all strings used. Special language resource files like e.g. res/values-de/strings.xml provides adjusted strings. If no special resource file exists, default is used. Matthias Keil 20. Oktober 2014 16 / 19 Multi-Language Support Example In Activity 1 tv = new TextView ( this ); 2 tv. settext (R. string. example ); In res/values/strings.xml 1 < string name =" example ">Example </ string > In res/values-de/strings.xml 1 < string name =" example ">Beispiel </ string > Matthias Keil 20. Oktober 2014 17 / 19 Summary User interfaces of activities are build through View and ViewGroup objects. ViewGroup subclasses are layouts that group other ViewGroup or View objects. View subclasses are widgets for user interaction like button, checkbox and so on. Enabling user interaction is implemented by capturing input events. Intents are messages and can be received through broadcast receivers. Multi-language support is implemented through resource files for strings. Matthias Keil 20. Oktober 2014 18 / 19

Bibliography Activities. http://developer.android.com/guide/topics/fundamentals/activities.html. Input Events. http://developer.android.com/guide/topics/ui/ui-events.html. Intents and Intent Filters. http://developer.android.com/guide/topics/intents/intents-filters.html. Localization. http://developer.android.com/guide/topics/resources/localization.html. User Interface. http://developer.android.com/guide/topics/ui/index.html. WebView. http://developer.android.com/reference/android/webkit/webview.html. XML Layouts. http://developer.android.com/guide/topics/ui/declaring-layout.html. Matthias Keil 20. Oktober 2014 19 / 19