MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.

Slides:



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

Android User Interface
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
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
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)
CS378 - Mobile Computing User Interface Basics MIKE!! LOOK HERE FOR intercepting the ListView items:
Android: Layouts David Meredith
Better reference the original webpage :
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Introducing the Sudoku Example
CS5103 Software Engineering Lecture 08 Android Development II.
PROG Mobile Java Application Development PROG Mobile Java Application Development Developing Android Apps: Components & Layout.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling.
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
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
CS378 - Mobile Computing Intents.
Mobile Computing Lecture#11 Adapters and Dialogs.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Engage! Android User Input, Variables,
Overview of Android Application Development
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Android Boot Camp for Developers Using Java, 3E
User Interfaces: Part 1 (View Groups and Layouts).
Configuring Android Development Environment Nilesh Singh.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
MOBILE COMPUTING D10K-7D02 MC04: Layouts Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
MOBILE COMPUTING D10K-7D02 MC03: Introduction to Android Programming Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas.
MOBILE COMPUTING D10K-7D02 MC07: Applications Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
Building User Interfaces Basic Applications
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
Chapter 2 Building User Interfaces and Basic Applications.
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.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Building UI Components Димитър Н. Димитров Astea Solutions AD.
Introduction to Android Programming
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.
Chapter 2: Simplify! The Android User Interface
Lab7 – Appendix.
Android Application Development 1 6 May 2018
Android – Event Handling
Mobile Application Development BSCS-7 Lecture # 8
MAD.
Creation of an Android App By Keith Lynn
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
CS323 Android Getting Started
Building User Interfaces Basic Applications
Android Developer Fundamentals V2
Emerging Platform#3 Android & Programming an App
Presentation transcript:

MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran

Mobile Computing Teknik Informatika-Semester Ganjil Android UI Design Referensi: Android Nerd Ranch, hal 1-30 Membuat aplikasi GeoQuiz Bisnis Proses: – App presents questions to test user’s knowledge of geography – User answers by pressing True or False buttons

Mobile Computing Teknik Informatika-Semester Ganjil GeoQuizz App Design 5 Widgets arranged hierarchical

Mobile Computing Teknik Informatika-Semester Ganjil GeoQuiz Application 2 main files: – activity_quiz.xml: to format app screen – QuizActivity.java: To present question, accept True/False response AndroidManifest.xml also auto‐generated

Mobile Computing Teknik Informatika-Semester Ganjil

Strings.xml

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java Initial QuizActivity.java code Would like java code to respond to True/False buttons being clicked

Mobile Computing Teknik Informatika-Semester Ganjil Responding to True/False Buttons in Java

Mobile Computing Teknik Informatika-Semester Ganjil Ways to Respond to Button Clicks 1.In XML: set android:onClick attribute 2.In java create a ClickListener object, override onClick method – typically done with anonymous inner class

Mobile Computing Teknik Informatika-Semester Ganjil Approach 1: Button that responds to Clicks Reference: Head First Android

Mobile Computing Teknik Informatika-Semester Ganjil Background: User Interface Elements When views (buttons, widgets, etc) are declared in XML are actually Java classes within Android Using XML declarations, Android actually creates corresponding Java objects (called inflating a view) View – basic building block for Android UI – Android class that represents a rectangular area on the screen – Responsible for drawing and event handling View is the super class for: – Textview, Imageview – Controls such as buttons, spinners, seek bars, etc. – ViewGroups which in turn is the super class for layouts

Mobile Computing Teknik Informatika-Semester Ganjil ViewGroups ‐ Layouts Layouts: – invisible containers that store other Views – Subclasses of ViewGroup Still a view but doesn't actually draw anything A container for other views Specifies options on how sub views (and view groups) are arranged

Mobile Computing Teknik Informatika-Semester Ganjil Approach 2: Create a ClickListener object, override onClick First, get reference to Button in our Java file. How?

Mobile Computing Teknik Informatika-Semester Ganjil R.Java Constants During compilation, XML resources (drawables, layouts, strings, views with IDs, etc) are assigned constants

Mobile Computing Teknik Informatika-Semester Ganjil Referring to Resources in Java File Can refer to resources in Java file using these constants Example In java file, R.java the constant corresponding to main.xml is argument of setContentView

Mobile Computing Teknik Informatika-Semester Ganjil Referencing Widgets by ID Many widgets and containers appear only in XML. E.g. TextView – No need to be referenced in Java code – To reference a widget in Java code, you need its android:id

Mobile Computing Teknik Informatika-Semester Ganjil Getting View References findViewById is implemented in base Activity class so it can be called in our java file (e.g. MainActivity.java) Argument of findViewById is constant of resource A generic view is returned (not subclasses e.g. buttons, TextView), so needs to cast

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java: Getting References to Buttons

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java: Setting Listeners Set listeners for True and False button

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java: Adding a Toast A toast is a short pop‐up message Does not require any input or action After user clicks True or False button, our app will pop‐up a toast to inform the user if they were right or wrong First, we need to add toast strings (Correct, Incorrect) to strings.xml

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java: Adding a Toast To create a toast, call the method: After creating toast, call toast.show( ) to display it For example to add a toast to our onClick( ) method:

Mobile Computing Teknik Informatika-Semester Ganjil QuizActivity.java: Adding a Toast

Mobile Computing Teknik Informatika-Semester Ganjil

Checkbox

Mobile Computing Teknik Informatika-Semester Ganjil Checkbox Has 2 states: checked and unchecked Clicking on checkbox toggles between these 2 states Used to indicate a choice (e.g. Add rush delivery) Since Checkbox widget inherits from TextView, its properties (e.g. android:textColor) can be used to format checkbox XML code to create Checkbox:

Mobile Computing Teknik Informatika-Semester Ganjil Making Checkbox Responsive 2 ways to make Checkbox responsive: 1. Set android:onClick attribute or 2. Create a ClickListener object, override onClick method, and register it with the checkbox In Java code, the following commands may be used – isChecked( ): to determine if checkbox has been checked – setChecked( ): to force checkbox into checked or unchecked state – toggle( ): to toggle current checkbox setting

Mobile Computing Teknik Informatika-Semester Ganjil Checkbox Example Java Code

Mobile Computing Teknik Informatika-Semester Ganjil Checkbox Example Result

Mobile Computing Teknik Informatika-Semester Ganjil Important Android Packages Android programs usually import packages at top. E.g. Important packages – android* Android application – dalvik* Dalvik virtual machine support classes – java.* Core classes and generic utilities (networking, security, math, etc) – org.apache.http: HTTP protocol support

Mobile Computing Teknik Informatika-Semester Ganjil Elemen Lain Toggle Button Switch Widget RadioButton RadioGroup SeekBar WebView widget Androdi App Components – Activities (already seen this) – Services – Content providers – Broadcast receivers

Mobile Computing Teknik Informatika-Semester Ganjil Konsep Android Android Process Model – Home, Back and Recents Button – Android Activity Stack Android Activity Life Cycle – Callback – Activity State diagram – Life cycle diagram Error logging in Android