Programming Mobile Applications with Android 22-26 September, Albacete, Spain Jesus Martínez-Gómez.

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

Programming with Android: Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Chapter 3: Engage! Android User Input, Variables, and Operations
Using Macros and Visual Basic for Applications (VBA) with Excel
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
User Interface Classes.  Design Principles  Views & Layouts  Event Handling  Menus  Dialogs.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Android Development (Basics)
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
Visual Basic Chapter 1 Mr. Wangler.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
CS5103 Software Engineering Lecture 08 Android Development II.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Chapter 2: Simplify! The Android User Interface
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Chapter 5 Creating User Interfaces GOALS and OBJECTIVES Begin our application by creating our user interface. More than one way to create a user interface.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Engage! Android User Input, Variables,
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Android Boot Camp for Developers Using Java, 3E
Android – Fragments L. Grewe.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Field Trip #32 Digital Alarm Clock By Keith Lynn.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Topics Introduction Scene Graphs
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Styles, Dialog Boxes, and Menus. Styles Allow creation of a common format – placed in res/values/styles.xml – file name is incidental Can be applied.
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences.
January 2006Colby College ITS Setting Up Course Pages.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
Building User Interfaces Basic Applications
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
Menus. Menus are a common user interface component in many types of applications. The options menu is the primary collection of menu items for an activity.
Lab7 – Appendix.
Android Programming - Features
CS499 – Mobile Application Development
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Android Topics Custom ArrayAdapters Creating an Event Listener
Android Developer Fundamentals V2
Programming Mobile Applications with Android
Android Developer Fundamentals V2
Mobile Programmming Dr. Mohsin Ali Memon.
Presentation transcript:

Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez

OSSCOM Programming Mobile Applications with Android 2 Programming Mobile Applications with Android ● Lesson 3.- Visual Interfaces – Visual elements.- Buttons, Text Areas, Spinners, Lists, etc – Layouts and Fragments.- How to organize the visual elements to improve visualization in different devices. – Menus and Action bars.- Some basics – Events.- How to handle and manage events – Android Lab III.- Create, compile and execute an application with different visual interfaces

OSSCOM Programming Mobile Applications with Android 3 Programming Mobile Applications with Android ● Lesson 3.- Visual Interfaces – In this lesson, we will learn: ● What are the visual elements that can be added to a layout, and when to use each one ● How to use the fragments to improve the graphical user interfaces ● How to add items to an options menu or action bar ● How to manage the events that handle the user actions

OSSCOM Programming Mobile Applications with Android 4 Programming Mobile Applications with Android ● Visual Elements – Button – RadioButton – CheckBox – ToogleBox – Spinner – TextView – EditText – ImageView – Others

OSSCOM Programming Mobile Applications with Android 5 Programming Mobile Applications with Android ● Visual Elements – Button ● Basic element that manages the user pressing ● It should be used to provoke important changes in the application

OSSCOM Programming Mobile Applications with Android 6 Programming Mobile Applications with Android ● Visual Elements – CheckBox ● Just two states: checked or not ● Actions over these elements should no invoke changes ● Used to create yes/no questionnaires

OSSCOM Programming Mobile Applications with Android 7 Programming Mobile Applications with Android ● Visual Elements – Spinner ● Selection from a large number of options ● The options should be defined – By means of programming – Using resource string-arrays

OSSCOM Programming Mobile Applications with Android 8 Programming Mobile Applications with Android ● Visual Elements – Spinner ● Using resource string arrays ● Edit the strings.xml file in the /res/values folder and add – – First – Second – Third – Fourth – ● Then, select the tempusSeasons as entries

OSSCOM Programming Mobile Applications with Android 9 Programming Mobile Applications with Android ● Visual Elements – ToogleButtons ● Just two states: checked or not ● Used as check box with associated changes

OSSCOM Programming Mobile Applications with Android 10 Programming Mobile Applications with Android ● Visual Elements – RadioButton ● Just two states: checked or not ● Several radio buttons can belong to the same group and then, only one can be selected ● They should be used for options with few answers

OSSCOM Programming Mobile Applications with Android 11 Programming Mobile Applications with Android ● Visual Elements – TextView ● Used for static text that requires no changes

OSSCOM Programming Mobile Applications with Android 12 Programming Mobile Applications with Android ● Visual Elements – EditText ● Used for the introduction of text from the user ● When it is focused, the android operative system loads the keyboard ● Several restrictions to the text introduced can be defined – Passwords (The text written is not visualized) – s – Telephone Numbers – Postal Address

OSSCOM Programming Mobile Applications with Android 13 Programming Mobile Applications with Android ● Visual Elements – ImageView ● Used for the visualization of images – System Images ● or – Resource Images ● Example: copy a new image to the res/drawable folder ● Add a new ImageView and select such Image

OSSCOM Programming Mobile Applications with Android 14 Programming Mobile Applications with Android ● Visual Elements – Others ● Rating Bars ● Progress Bars ● Seek Bars ● Gallery ● Digital Clock ● Calendar View ●...

OSSCOM Programming Mobile Applications with Android 15 Programming Mobile Applications with Android ● Visual Elements – Visual elements or Views are added in two steps ● Step 1.- Load them into the layout and establish the preferences (visualization, text, appearance, etc) and remember the Id for future use. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Press" />

OSSCOM Programming Mobile Applications with Android 16 Programming Mobile Applications with Android ● Visual Elements – Visual elements or Views are added in two steps ● Step 2.- Create a new reference in the code of the activity to perform changes in the element – Create a global reference and link it to the name used on the layout final Button myButton = (Button)findViewById(R.id.myButton); – Now, we can access a set of methods from the class View

OSSCOM Programming Mobile Applications with Android 17 Programming Mobile Applications with Android ● Layout and Fragments – Layouts define the visualization of the elements included in the layout ● Different types: relative, linear, grid, frame, table – Fragments are used to describe a partial visualization of the activity ● A fragment has its own life-cycle – Resumed – Paused – Stopped – Fragments are more complicated but complex

OSSCOM Programming Mobile Applications with Android 18 Programming Mobile Applications with Android ● Layouts – Please experiment with the different types of layouts adding some elements like buttons and textFields

OSSCOM Programming Mobile Applications with Android 19 Programming Mobile Applications with Android ● Fragments – They started with the release of bigger devices like tablets – There two different ways to add a fragment ● Define it in the layout file → static ones ● Create them by programming → dynamic ones – Must be associated with a subclass of the Fragment class → new methods ● OnAttach(), onCreate(), onCreateView(), onActivityCreated(), onDetach(),etc

OSSCOM Programming Mobile Applications with Android 20 Programming Mobile Applications with Android ● Fragments – basic usage – Fragments can be used to create menus ● For instance: we create a menu where the first level shows the course days and once a year has been selected, the overall description is shown. – What do we need ? ● Two different.java fragment files ● A single.java activity class ● Three layouts: 1 for the main activity and 2 for the fragments

OSSCOM Programming Mobile Applications with Android 21 Programming Mobile Applications with Android ● Fragments – basic usage – MainClass ● Layout: linear layout with two fragments (A and B) ● Class: extends activity and implements ListSelectionListener – Receives the index of the element selected in Fragment A – Calls a method in Fragment B with the index

OSSCOM Programming Mobile Applications with Android 22 Programming Mobile Applications with Android ● Fragments – basic usage – Fragment A ● Layout: just and empty TextView (for ListFragment cast) ● Class: extends ListFragment – Each time a element is selected, it is invoked a function in the main class – When the activity is created, it is filled with the name of the days as a List

OSSCOM Programming Mobile Applications with Android 23 Programming Mobile Applications with Android ● Fragments – basic usage – Fragment B ● Layout: just and empty TextView ● Class: extends Fragment – Key method: showInformationForDay(i), establish the text of the TextView when called from the main Activity Fragment A Day 1 Day 2... Fragment B The first day, the basic... Main Class selected1 !! ShowInformation ForDay(1)

OSSCOM Programming Mobile Applications with Android 24 Programming Mobile Applications with Android ● Fragments – basic usage Fragment A Day 1 Day 2... Fragment B The first day, the basic... Main Class selected1 !! ShowInformation ForDay(1)

OSSCOM Programming Mobile Applications with Android 25 Programming Mobile Applications with Android ● Other visual elements: Menus and Action Bar – Menus can be easily defined using a resource file, within the /res/menu folder – For instance, we can modify the main.xml file created as default and add the following lines

OSSCOM Programming Mobile Applications with Android 26 Programming Mobile Applications with Android ● Other visual elements: Menus – Then, there are two methods to implement public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); return true;} public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item1: Toast.makeText(getApplicationContext(), "Option 1 selected",Toast.LENGTH_SHORT).show();... return false; }}

OSSCOM Programming Mobile Applications with Android 27 Programming Mobile Applications with Android ● Other visual elements: Menus – Menu items can also be – associated to shortcut keys – There are option menus and – context menus (associated to – view elements) ● Step A for context menus – Link ViewElement ↔ Menu: registerForContextMenu(elemVar)

OSSCOM Programming Mobile Applications with Android 28 Programming Mobile Applications with Android ● Other visual elements: Menus – There are option menus and – context menus (associated to – view elements) ● Step B for context menus – Create the menu and associate elements with actions ● onCreateContextMenu ● onContextItemSelected

OSSCOM Programming Mobile Applications with Android 29 Programming Mobile Applications with Android ● Other visual elements: Action Bar – It is located at the top and can display icons, a descriptive title or interactive items – Items should be used to provide direct links to operations with high interest – The methods to add and manage items are the same as for the options menu ● You can add android:showAsAction="never" to avoid show actions in the menu – You can play with the code using a direct reference: ActionBar actionBar = getActionBar();

OSSCOM Programming Mobile Applications with Android 30 Programming Mobile Applications with Android ● Events.- How to handle and manage events? – Events: dynamic part of the android applications – The are two overall type of events ● Those performed over specific View elements – Button is pressed – Some text introduced in a text field – An image has been clicked – …

OSSCOM Programming Mobile Applications with Android 31 Programming Mobile Applications with Android ● Events.- How to handle and manage events? – The are two overall type of events ● Those performed over the whole activity – Click – A key has been pressed – Classes in charge of the management of events ● Listener → are executed automatically

OSSCOM Programming Mobile Applications with Android 32 Programming Mobile Applications with Android ● Events.- List of common events – Onclick – ScrollX – ScrollY – ScrollBarSize – LongClickable – OverScrollMode – Padding – Focusable

OSSCOM Programming Mobile Applications with Android 33 Programming Mobile Applications with Android ● Events.- View element events – A button has been pressed final Button myButton = (Button)findViewById(R.id.myButton); myButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(MainActivity.this, "Button Pressed",Toast.LENGTH_LONG).show(); } });

OSSCOM Programming Mobile Applications with Android 34 Programming Mobile Applications with Android ● Events.- View element events – Enter key has been inserted in a text edit final EditText myEditText = (EditText) findViewById(R.id.editText1); myEditText.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_ENTER) Toast.makeText(MainActivity.this, "Enter",Toast.LENGTH_LONG).show(); return false; } });

OSSCOM Programming Mobile Applications with Android 35 Programming Mobile Applications with Android ● Events.- View element events – The element of a spinner has been selected final Spinner mySpinner = (Spinner) findViewById(R.id.spinner1); mySpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view,int position, long id) { Toast.makeText(MainActivity.this, "It has been selected the item at position "+position,Toast.LENGTH_LONG).show(); } public void onNothingSelected(AdapterView parent) { Toast.makeText(MainActivity.this, "No item has been selected",Toast.LENGTH_LONG).show(); } });

OSSCOM Programming Mobile Applications with Android 36 Programming Mobile Applications with Android ● Events.- View element events – The whole activity can also be prepared to respond to events. – In this case, the activity class has to implement some of the following methods ● OnClickListener ● OnLongClickListener ● OnKeyListener ● OnTouchListener – The class has to include the related methods

OSSCOM Programming Mobile Applications with Android 37 Programming Mobile Applications with Android ● Android Lab III.- Create, compile and execute an application with different visual interfaces – Follow the instructions to create the same android application with events management and different visualizations

OSSCOM Programming Mobile Applications with Android 38 Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez