Mobile Computing Lecture#11 Adapters and Dialogs.

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.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
 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.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Presenting Lists of Data. Lists of Data Issues involved – unknown number of elements – allowing the user to scroll Data sources – most common ArrayList.
Android: Layouts David Meredith
Android Application Development 2013 PClassic Chris Murphy 1.
Android UI, and Networking. Can do most networking on Android Bluetooth only on 2.0, Not supported with version 1.6.
Better reference the original webpage :
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
1 Interface Types & Polymorphism & introduction to graphics programming in Java.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Content providers Accessing shared data in a uniform way 1Content providers.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Creating Multimedia Interaction with Windows Media Technologies 7.
Android Dialog Boxes AlertDialog - Toast
Engage! Android User Input, Variables,
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
Android Boot Camp for Developers Using Java, 3E
Address Book App 1. Define styles   Specify a background for a TextView – res/drawable/textview_border.xml.
Chapter 7: Reveal! Displaying Pictures in a Gallery.
Cosc 5/4730 Dialogs and below 3.0 and above (fragment)
Chapter 5: Windows and Frames
Copyright © 2002 Systek The Adapter Pattern Overview And Experience Report Johannes Brodwall, Systek AS.
© 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.
User notification Android Club Agenda Toast Custom Toast Notification Dialog.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
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.
DKU-MUST Mobile ICT Education Center 11. AdapterView.
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
ListView and ExpandableListView
Adapters 1 CS440. Adapters (again!)  Adapters are bridging classes, that bind data to user-interface Views. The adapter is responsible for creating the.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
Creating and Using Dialogs ● A dialog is a box that pops up and prompts the user for a value or informs them of something ● One way: directly create objects.
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.
More App Customizations. Overview  Application/ Activity Customizations: Themes  Menu Customizations  Custom Dialogs  Custom Toasts  Custom Buttons.
Address Book App 1 Fall 2014 CS7020: Game Design and Development.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Java for android Development Nasrullah Khan. Using instanceof in Android Development the classes such as Button, TextView, and CheckBox, which represent.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
CS499 – Mobile Application Development
Mobile Application Development BSCS-7 Lecture # 9
ListView: Part 2.
Mobile Application Development BSCS-7 Lecture # 8
ITEC535 – Mobile Programming
Mobile Application Development BSCS-7 Lecture # 13
Android Dialog Boxes AlertDialog - Toast
Mobile Computing With Android ACST 4550 Alerts
Android Programming Lecture 6
Predefined Dialog Boxes
ANDROID LISTS.
Android Lists and Fragments
Android Topics Custom ArrayAdapters
Android Developer Fundamentals V2
HNDIT2417 Mobile Application Development
ListView ? BaseAdapter ?.
Reactive Android Development
Mobile Programming Dr. Mohsin Ali Memon.
Presentation transcript:

Mobile Computing Lecture#11 Adapters and Dialogs

Lecture Contents  Adapter  SimpleCursorAdapter  ArrayAdapter  Dialog  Dialog Class  Dialog-themed Activity  Toasts 2

Adapters Adapters are bridging classes that bind data to Views (such as List Views) used in the user interface. The adapter is responsible for 1. Creating the child Views used to represent each item within the parent View (say a ListView) 2. Providing access to the underlying data (say an ArrayList) 3

Simple Cursor Adapter  An easy adapter to map columns from a cursor to TextViews or ImageViews  You can specify which columns you want, which views you want to display the columns, and the XML file that defines the appearance of these views. 4

Simple Cursor Adapte Example 5

6

ArrayAdapter  The Array Adapter uses generics to bind an Adapter View to an array of objects of the specified class  By default the Array Adapter uses the toString() value of each object in the array to create and populate Text Views  Alternative constructors enable you to use more complex layouts  You can even extend the class to use alternatives to Text Views (to display data) 7

ArrayAdapter Example Steps Involved:::: 1. Layout Definitions 2. Adapter Class 3. Activity to show elements 8

ArrayAdapter Example (Adapter Class) 9

10 ArrayAdapter Example (Main Class)

ArrayAdapter Example (row.xml) 11

ArrayAdapter Example (main.xml) 12

ArrayAdapter Example (Output) 13

ArrayAdapter Complex Example Steps Involved:::: 1. Layout Definitions 2. View Data Class 3. Adapter Class 4. Activity to show elements 14

Layouts 15

Data Class 16

Student Adapter 17

Main 18

Dialogs  Dialog boxes are a common UI metaphor in desktop, web, and mobile applications  They’re used to help users answer questions, make selections, and confirm actions, and to display warning or error messages  Dialog boxes in Android are partially transparent, floating Activities that appear upon activities that launch them 19

Implementing Dialogs There are three ways to implement a dialog in Android: 1. Using Dialog class 2. Dialog-themed Activity 3. Toasts 20

Using Dialog Class or Its Extensions  Android includes a number of specialist classes that extend Dialog  Each is designed to provide specific dialog-box functionality  Dialog-class-based screen is constructed entirely within its calling Activity, so it doesn’t need to be registered in the manifest  Dialog’s life cycle is controlled entirely by the calling Activity 21

Dialog Creation Dialog d = new Dialog(MyActivity.this); // Have the new window tint and blur the window it obscures. Window window = d.getWindow(); int flag = WindowManager.LayoutParams.FLAG_BLUR_BEHIND; window.setFlags(flag, flag); d.setTitle("Dialog Title"); // Set title d.setContentView(R.layout.dialog_view); // Inflate layout // Find the TextView used in the layout and set its text value TextView text = (TextView)d.findViewById(R.id.dialog); text.setText("This is the text in my dialog"); d.show(); 22

Dialog output 23

Dialog with Buttons final Context context = Main.this; String title = "It is Pitch Black"; String message = "You are likely to be eaten by a ghost"; String button1String = "Go Back"; String button2String = "Move Forward"; AlertDialog.Builder ad = new AlertDialog.Builder(context); ad.setTitle(title); d.setMessage(message); ad.setPositiveButton(button1String, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { //Do something positive } }); ad.setNegativeButton(button2String, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int arg1) { //Do something negative } }); ad.show(); 24

Dialog with Buttons 25

Toast  Android allows us to display a message without any button like 'OK' or 'Cancel'  Its helps us to display a short message in short time  Call Toast.makeText()  Provide necessary arguments (Context, Message, Duration)  Call show() message to display toast 26

Syntax/Example 27  Toast Syntax Toast.makeText(Context, Message, Duration).show() ToastExample::::: Toast.makeText(MyActivity.this, “You have been assigned a project”, Toast.LENGTH_LONG).show();

Custom Toast Toast toast = new Toast(MyActivity.this); TextView toastView = new TextView(MyActivity.this); toastView.setText("Here goes your message"); toastView.setBackgroundColor(Color.WHITE); toastView.setTextColor(Color.RED); toastView.setPadding(10,10,10,10); toast.setView(toastView); toast.setDuration(Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); 28

Regular/Custom Toast 29