Android Developer Fundamentals V2

Slides:



Advertisements
Similar presentations
Android User Interface
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
 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.
Cosc 5/4730 Material Design Spec’s and Toolbar.. Material Design First and for most, Material Design is a spec used by android to have app look similar.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Basic Functionality in Android. Functionality in Android Events in Java – mouse related mouse clicked button down or up mouse entered – many others key.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
CS378 - Mobile Computing User Interface Basics MIKE!! LOOK HERE FOR intercepting the ListView items:
Chapter 9 Working with Forms. Principles of Web Design 2nd Ed. Chapter 9 2 Principles of Web Design Chapter 9 Objectives Understand how forms work Understand.
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.
Android Hard & Soft Keyboards Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC.
PROG Mobile Java Application Development PROG Mobile Java Application Development Developing Android Apps: Components & Layout.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
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.
Understanding Hello Android 1 CS300. Activity  Similar to a form  Base class for the visual, interactive components of your application  Android API.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
GUI Widgets Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
Engage! Android User Input, Variables,
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Presented By: Muhammad Tariq Software Engineer Android Training course.
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Designer Basics.
Week 12 Working with Forms Objectives Understand how forms work Understand form syntax Create input objects Build forms within tables Build and.
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.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
1. Chapter 20 Managing Shared Documents 3 Working Together on Documents Word provides features to help workgroup members collaborate on documents. Insert.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
© 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.
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
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Chapter 2 Building User Interfaces and Basic Applications.
Interstage BPM v11.2 1Copyright © 2010 FUJITSU LIMITED FORMS.
CS371m - Mobile Computing User Interface Basics. UI Programming with Widgets Widget is an element in a Graphical User Interface (GUI) – not to be confused.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
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 –
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Section 10.1 Define scripting
Cosc 5/4730 RecyclerView And more..
Chapter 5 Validating Form Data with JavaScript
CS240: Advanced Programming Concepts
Microsoft Access 2007 – Level 2
Android – Event Handling
Android Hard & Soft Keyboards
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Database Applications – Microsoft Access
Database Applications – Microsoft Access
Building User Interfaces Basic Applications
Android Developer Fundamentals V2
Android Topics Limited Resources and why we need to consider them.
Mobile Programmming Dr. Mohsin Ali Memon.
Creating Additional Input Items
User Interface Screen Elements
User Interface Screen Elements
CS 240 – Advanced Programming Concepts
Presentation transcript:

Android Developer Fundamentals V2 User Interaction Lesson 4

Accepting user input Freeform text and numbers: EditText (using keyboard) Providing choices: CheckBox, RadioButton, Spinner Switching on/off: Toggle, Switch Choosing value in range of values: SeekBar

Examples of input controls EditText SeekBar CheckBox RadioButton Switch Spinner

How input controls work Use EditText for entering text using keyboard Use SeekBar for sliding left or right to a setting Combine CheckBox elements for choosing more than one option Combine RadioButton elements into RadioGroup — user makes only one choice Use Switch for tapping on or off Use Spinner for choosing a single item from a list

View focus

Clickable versus focusable Clickable—View can respond to being clicked or tapped Focusable—View can gain focus to accept input Input controls such as keyboards send input to the view that has focus

Focus The View that receives user input has "Focus" Only one View can have focus Focus makes it unambiguous which View gets the input Focus is assigned by User tapping a View App guiding the user from one text input control to the next using the Return, Tab, or arrow keys Calling requestFocus() on any View that is focusable

Which View gets focus next? Topmost view under the touch After user submits input, focus moves to nearest neighbor—priority is left to right, top to bottom Arrange input controls in a layout from left to right and top to bottom in the order you want focus assigned Specify ordering in XML android:id="@+id/top" android:focusable="true" android:nextFocusDown="@+id/bottom"

Set focus explicitly Use methods of the View class to set focus setFocusable() sets whether a view can have focus requestFocus() gives focus to a specific view setOnFocusChangeListener() sets listener for when view gains or loses focus onFocusChanged() called when focus on a view changes

Find the view with focus Activity.getCurrentFocus() ViewGroup.getFocusedChild()

Freeform text and numbers

EditText for multiple lines of text EditText default Alphanumeric keyboard Suggestions appear Tapping Return (Enter) key starts new line Return key

Customize with inputType Set in Attributes pane of layout editor XML code for EditText: <EditText android:id="@+id/name_field" android:inputType = "textPersonName" ...

EditText for message android:inputType ="textShortMessage" Single line of text Tapping Emoticons key changes keyboard to emoticons Emoticons

EditText for single line Both work: android:inputType ="textLongMessage" android:inputType ="textPersonName" Single line of text Tapping Done key advances focus to next View Done key

EditText for phone number entry android:inputType ="phone" Numeric keypad (numbers only) Tapping Done key advances focus to next View Done key

Getting text Get the EditText object for the EditText view EditText simpleEditText = findViewById(R.id.edit_simple); Retrieve the CharSequence and convert it to a string String strValue = simpleEditText.getText().toString();

Input types Common input types textCapCharacters: Set to all capital letters textCapSentences: Start each sentence with a capital letter textPassword: Conceal an entered password number: Restrict text entry to numbers textEmailAddress: Show keyboard with @ conveniently located phone: Show a numeric phone keypad datetime: Show a numeric keypad with a slash and colon for entering the date and time

Providing choices

UI elements for providing choices CheckBox and RadioButton ToggleButton and Switch Spinner

CheckBox User can select any number of choices Checking one box does not uncheck another Users expect checkboxes in a vertical list Commonly used with a Submit button Every CheckBox is a View and can have an onClick handler

RadioButton Put RadioButton elements in a RadioGroup in a vertical list (horizontally if labels are short) User can select only one of the choices Checking one unchecks all others in group Each RadioButton can have onClick handler Commonly used with a Submit button for the RadioGroup

Toggle buttons and switches User can switch between on and off Use android:onClick for click handler Toggle buttons Switches

RecyclerView

What is a RecyclerView? RecyclerView is scrollable container for large data sets Efficient Uses and reuses limited number of View elements Updates changing data fast

How components fit together overview Components

Layout Manager What is a layout manager? Use to position View items inside a RecyclerView Reuses View items that are no longer visible to the user Built-in layout managers LinearLayoutManager GridLayoutManager StaggeredGridLayoutManager Extend RecyclerView.LayoutManager

Adapter What is an adapter? Helps incompatible interfaces work together Example: Takes data from database Cursor and prepares strings to put into a View Intermediary between data and View Manages creating, updating, adding, deleting View items as underlying data changes RecyclerView.Adapter

Adapter What is a ViewHolder? Used by the adapter to prepare one View with data for one list item Layout specified in an XML resource file Can have clickable elements Is placed by the layout manager RecyclerView.ViewHolder

Implementing RecyclerView

Implementation Steps Summary Add RecyclerView to layout Create XML layout for item Extend RecyclerView.Adapter Extend RecyclerView.ViewHolder In Activity onCreate(), create RecyclerView with adapter and layout manager

Activity layout Add RecyclerView to XML Layout <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v7.widget.RecyclerView>

Item layout Create layout for 1 list item <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listitem" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/word" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout>

Adapter: Create Implement the adapter public class WordListAdapter extends RecyclerView.Adapter <WordListAdapter.WordViewHolder> { ArrayList<String> mWordList; public WordListAdapter(ArrayList<String> wordList) { this.mWordList=wordList; } }

Adapter: onCreateViewHolder() Adapter has 3 required methods inBindViewHolder() getItemCount() Let's take a look!

Adapter: onCreateViewHolder() onCreateViewHolder() @Override public WordViewHolder onCreateViewHolder(ViewGroup parent,int viewType){ // Inflate an item view. View mItemView = LayoutInflater.from( parent.getContext()).inflate(R.layout.listitem, parent, false); return new WordViewHolder(mItemView); }

Adapter: onBindViewHolder() onBindViewHolder() @Override public void onBindViewHolder(WordViewHolder holder, int position) { holder.wordItemView.setText(mWordList.get(position)); } @Override public int getItemCount() { return mWordList.size(); }

Adapter: ViewHolder Class Create the view holder in adapter class class WordViewHolder extends RecyclerView.ViewHolder { public TextView wordItemView; public WordViewHolder(View itemView) { super(itemView); wordItemView = itemView.findViewById(R.id.word); // itemView.setOnClickListener(this); } } If you want to handle mouse clicks: class WordViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { //.. }

Create RecyclerView Create the RecyclerView in Activity onCreate() mRecyclerView = findViewById(R.id.recyclerview); mAdapter = new WordListAdapter(mWordList); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

END