Cosc 5/4730 Dialogs 2.3.3 and below 3.0 and above (fragment)

Slides:



Advertisements
Similar presentations
Welcome to WebCRD.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Copyright© Jeffrey Jongko, Ateneo de Manila University Dialogs, Custom Dialogs, Toasts.
WPML Translation plugin is the best option when you need to translate your Wordpress website into multiple languages. The plugin makes it easy to translate.
User Interface Classes.  Design Principles  Views & Layouts  Event Handling  Menus  Dialogs.
Android Fragments.
Cosc 4730 Android Dialogs and notifications. Notifications There are a couple of ways to notify users without interrupting what they are doing The first.
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.
Android Development (Basics)
Android Application Development 2013 PClassic Chris Murphy 1.
How to Check Books In and Out (as well as other library materials) A tutorial for librarians who use Agent VERSO.
JQuery CS 268. What is jQuery? From their web site:
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
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.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Mail merge I: Use mail merge for mass mailings Perform a complete mail merge Now you’ll walk through the process of performing a mail merge by using the.
 INSTRUCTOR: Message Center Arlene Zimmerly, Coauthor Gregg College Keyboarding & Document Processing, 11e Note: This presentation is intended.
Mobile Computing Lecture#11 Adapters and Dialogs.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Android – Fragments L. Grewe.
IReport Demo Spring 2008 OEDSA Conference. Report Properties.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
5-1 More UI CSNB544 Mobile Application Development Thanks to Utexas Austin.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
User notification Android Club Agenda Toast Custom Toast Notification Dialog.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Using Advanced Options Lesson 14 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Basic & Advanced Reporting in TIMSNT ** Part Three **
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Creating a Multiple-Form Interface.
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.
American Work ® Expense Reporting: End User Training.
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.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Android: “Dynamic” data and Preferences data.
© 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.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Android Drawing Units and The.
Frank Xu Gannon University. A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within.
More UI Action Bar, Navigation, and Fragments
CS378 - Mobile Computing More UI. UI Review Containers – more formally ViewGroups – store widgets and other containers – examples: LinearLayout, RelativeLayout,
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
© 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.
COMP 365 Android Development.  Developing for Android  XML for user interface formatting and other scripting  Java for programming.
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Уведомление пользователя ANDROID CLUB Сегодня  Toast  Диалог  Уведомление.
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
Java for android Development Nasrullah Khan. Using instanceof in Android Development the classes such as Button, TextView, and CheckBox, which represent.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
ANDROID DIALOGS. Slide 2 Dialogs (Introduction) The Dialog class is the base class for all dialogs A dialog is a small window that prompts the user to.
UI Redux, Navigation Patterns, Tabbed Views, Pagers, Drawers
Wiring Fragments Wiring Dialogs. Ask FragmentManager whether home Fragment exists If not, create home Fragment Add it Main Activity setContentView Launch.
Cosc 4735 Nougat API 24+ additions.
Android Programming - Features
CS499 – Mobile Application Development
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Mobile Computing With Android ACST 4550 Alerts
Review 2: Material Design and key widgets.
Android: Preferences and user settings data
Android Developer Fundamentals V2
Android Developer Fundamentals V2 Lesson 4
Activities and Fragments
Cosc 5/4730 EmojiCompat library..
Implication of Orientation Changes
Presentation transcript:

Cosc 5/4730 Dialogs and below 3.0 and above (fragment)

Dialogs So most of this is depreciated in API 13+, but it is encapsulated in a fragment, plus if you are writing from below API 13 (honeycomb) it’s worth knowing.

Dialog A dialog is always created and displayed as a part of an Activity. – You should normally create dialogs from within your Activity's onCreateDialog(int) callback method

Dialog Using the createDialog() method – All dialog creation is done there. – Only called the first time specfic dialog is created. Use the onPrepareDialog(int, Dialog) – Every time the dialog is called, you can modify it In you activity: – showDialog(DIALOG_PAUSED_ID); Where is the ID is the dialog you want to display.

Creating a Dialog There are several dialogs you can create – AlertDialog, which can have up to 3 buttons – ProgressDialog – DatePickerDialog and TimePickerDialog – Custom dailog, which you create the layout.

AlertDialog Use the AlertDialog.Builder to create the dialog – You can have up to three buttons, “positive”, “negative” and cancel – To create the following Dialog Set the positive and negative, and disable cancel.

AlertDialog (2) Code: with two listeners, one for each button. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Winner!").setCancelable(false).setPositiveButton("Next Level", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); //next(); } }).setNegativeButton("Quit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); dialog = builder.create();

AlertDialog (3) Instead of buttons, you can have it as radio buttons (and more then just three); – Use Builder.setSignleChoiceItems Where we send a CharSequence[] of items. final String[] items = {"Remove Walls", "Add Walls", "Add/Remove Objects", "Add/Remove Score"};

AlertDialog (4) code: final String[] items = {"Remove Walls", "Add Walls", "Add/Remove Objects", "Add/Remove Score"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Type:"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); if (item == 0) { //remove walls } }); dialog = builder.create();

Custom Dialogs You need to create a layout xml file for the dialog – Then dialog.setContentView(R.layout.youlayout) – Using dialog.findViewByID(R.id.X) to access each widget to set images and/or listeners as necessary – dialog.setTitle(“your title”); – Now it’s ready to be shown.

Examples The previous examples are all shown in dialogs233Activity in the DialogDemo

DialogFragments The showDialog is depreicated in API 13+ – Links and discussion of dialogfragment vs alertdiags: alogfragment-advantages-over-alertdialog alogfragment-advantages-over-alertdialog Basically, I’m just going to show how it works. What it comes down to is that you are creating custom dialogs. – But we can still use the alertdialog creators in the dialogfragment as well.

DialogFragment Basically a fragment and everything that we have already done. Or you implement onCreateDialog(Bundle) – Instead of (or in addition to ) onCreateView DialogFragments can be added to a framelayout just like fragments OR we can show it like a dialog. – All the demos are going to show it, instead putting in the framelayout, since you already saw how to do it.

EditNameDialogFrag example Looking at the code, it is a DialogFragment (using support library or without is the same) Create a callback as we have done before In onCreateView – Inflate the layout, return the view. Just like we have done before. The change is in the FragmentDialogActivity. FragmentManager fm = getSupportFragmentManager(); EditNameDialogFrag editNameDialog = new EditNameDialogFrag(); editNameDialog.show(fm, "fragment_edit_name"); Show function, causes the dialogFragment to popup on the screen.

EditNameDialogFrag example (2) So we have the dialog

EditNameDialogFrag and keyboard Changing the keyboard return button to done. – In the xml for the EditText <EditText … android:inputType="text" android:imeOptions="actionDone" /> – Changes keyboard – Setup in the listener if (EditorInfo.IME_ACTION_DONE == actionId) – We know when they done editing/typing. – A note, this doesn’t work correctly in the emulators, so I added done button to the example.

DialogFragment and AlertDialog We can embed the alertDialogs into the FragmentDialog, so you can use the “default” dialogs as well. – Shown in code DialFragActivity and AlertDialogFrag1 and myDialogFragment

DialogFragment with AlertDialog Two pieces for the Dialog Fragment newInstance – Creates a new dialogFragment, instead doing this in the Activity. onCreateDialog – Creates the AlertDialog via the builder just like before. Then use callbacks in the positive/negative

DialogFragment with AlertDialog (2) In the fragment new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mlistener.doPositiveClick(); //using “normal” callbacks. }} In the Activity: public void doPositiveClick() { // Do stuff here. }

Example code DialFragActivity – AlertDialogFrag1 Cancel/Ok dialog – myDialogFragment Implements the two dialog from the beginning of the lecture No/Yes, and a ListDialog – There is a doPositivieClick(), doNegativeClick(), and doItem(String) for these dialog Implemented via the callbacks.

DialogFragment References oid/app/DialogFragment.html oid/app/DialogFragment.html developers.blogspot.com/2012/05/using- dialogfragments.html developers.blogspot.com/2012/05/using- dialogfragments.html 1/simplest-yes-no-dialog-fragment 1/simplest-yes-no-dialog-fragment

Q A &