Android Hard & Soft Keyboards Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © 2008-2009 CommonsWare, LLC.

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

Tutorial 6 Creating a Web Form
Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android Form Elements. Views Provide common UI functionality Form elements: text area, button, radio button, checkbox, dropdown list, etc. Date and time.
Chapter 7 Improving the User Interface
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
1 CGS1060 Mobile UIs Copyright 2012 by Janson Industries.
1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Introducing the Sudoku Example
Chapter 4 Handling User Input PHP Programming with MySQL 2nd Edition
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Neal Stublen Improvements  New form elements  Assist with validation  Consistency across sites  Changes reduce the need for common.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Understanding Hello Android 1 CS300. Activity  Similar to a form  Base class for the visual, interactive components of your application  Android API.
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.
 A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. What is Database?
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Engage! Android User Input, Variables,
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Application Development for mobile Devices
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR TO PUT IT SIMPLY A GENERAL PURPOSE CONTAINER FOR STORING.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Introduction to Database using Microsoft Access 2013 Part 6.1 November 18, 2014.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
© 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.
Android and s Ken Nguyen Clayton state University 2012.
HTML 5 Form elements Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Form Validation. Create a form for the user to enter the data seen blow.
Microsoft Access Prepared by the Academic Faculty Members of IT.
Building User Interfaces Basic Applications
Tutorial 6 Creating a Web Form
| Mobile Accessibility Development Making an Accessible App Usable Scott McCormack.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
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 –
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Android Programming.
EET 2259 Unit 13 Strings and File I/O
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
3 Introduction to Classes and Objects.
Introduction to the C Language
Android Introduction Hello World.
Android Hard & Soft Keyboards
Activities and Intents
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Politeknik Elektronika Negeri Surabaya
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
CIS 470 Mobile App Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
CIS 470 Mobile App Development
Android Developer Fundamentals V2
CIS 470 Mobile App Development
Android Notifications
EET 2259 Unit 13 Strings and File I/O
Android Sensor Programming
Android Sensor Programming
Presentation transcript:

Android Hard & Soft Keyboards Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN: & Android Developers 7B

2 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 2 Android r1.5 introduced the notion of Input Method Framework (IMF). The idea is to let the IFM arbitrate the interaction between applications and the current input method chosen by the user. The motivation behind this framework is the realization that as Android matures, more hardware /software devices, and input techniques will appear in user’s applications, for instance: real & virtual keyboards, voice recognition, hand writing, etc…

3 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 3 Keyboarding data into Android’s applications is functionally dependent of the hardware present in the actual device. HTC – G1 Sliding Window exposes (occasionally) a hard keyboard Samsung Model shows a permanent hard keyboard HTC - Magic Model shown has no hard keyboard

4 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 4 The IMF is aware of the available hardware and its current state. If there is no a readily available hardware keyboard, an input method editor (IME) will be made available to the user when they tap on an enabled EditText. Soft Keyboard Enabled EditText

5 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 5 Telling Android what data to expect TextViews can indicate by XML attribute or Java method the expected type of a text field: android:inputType=“...” editTextBox.setRawInputType(int) This way Android knows the type of data to be placed in a text field. Knowing the type is useful in deciding what appropriated input method could be applied to help the user enter text. XML Java

6 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 6 Constant ValueDescription none 0x There is no content type. The text is not editable. text 0x Just plain old text. textCapCharacters 0x Can be combined with text and its variations to request capitalization of all characters. textCapWords 0x Can be combined with text and its variations to request capitalization of the first character of every word. textCapSentences 0x Can be combined with text and its variations to request capitalization of the first character of every sentence. textAutoCorrect 0x Can be combined with text and its variations to request auto- correction of text being input. Android:inputType Values

7 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 7 Constant ValueDescription textAutoComplete 0x Can be combined with text and its variations to specify that this field will be doing its own auto-completion and talking with the input method appropriately. textMultiLine 0x Can be combined with text and its variations to allow multiple lines of text in the field. If this flag is not set, the text field will be constrained to a single line. textImeMultiLine 0x Can be combined with text and its variations to indicate that though the regular text view should not be multiple lines, the IME should provide multiple lines if it can. Android:inputType Values

8 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 8 Constant ValueDescription textUri 0x Text that will be used as a URI. text Address 0x Text that will be used as an address. text Subject 0x Text that is being supplied as the subject of an . textShortMessage 0x Text that is the content of a short message. textLongMessage 0x Text that is the content of a long message. textPersonName 0x Text that is the name of a person. textPostalAddress 0x Text that is being supplied as a postal mailing address. textPassword 0x Text that is a password. textVisiblePassword 0x Text that is a password that should be visible. textWebEditText 0x000000a1Text that is being supplied as text in a web form. Android:inputType Values

9 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 9 Constant ValueDescription textFilter 0x000000b1Text that is filtering some other data. textPhonetic 0x000000c1 Text that is for phonetic pronunciation, such as a phonetic name field in a contact entry. number 0x A numeric only field. numberSigned 0x Can be combined with number and its other options to allow a signed number. numberDecimal 0x Can be combined with number and its other options to allow a decimal (fractional) number. phone 0x For entering a phone number. datetime 0x For entering a date and time. date 0x For entering a date. time 0x For entering a time. Android:inputType Values

10 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 10 Example1: Using android:text="inputType: text|textCapWords" <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffcccccc" android:orientation="vertical" xmlns:android=" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ff0000ff" android:text="inputType: text|textCapWords" android:textStyle="bold" android:textSize="22sp" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10px" android:textSize="18sp" android:inputType="text|textCapWords" /> Multiple types of input methods could be combined. Use “pipe” symbol | to separate the options. In the example a soft text keyboard is used, in addition it should proper capitalize each word

11 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 11 Example1: Using android:text="inputType: text|textCapWords" After tapping the EditBox a soft keyboard appears showing CAPITAL letters After first letter is typed the Keyboard switches automatically to LOWER case to complete the word. After entering space the keyboard repeats cycle beginning with UPPER case, then LOWER case letters.

12 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 12 Example2: Using android:inputType="number|numberSigned|numberDecimal" 1.The keyboard displays numbers. 2.In general other non-numeric keys are visible but disable. 3.Only valid numeric expressions can be entered. 4.Type number|numberSigned accepts integers. 5.Type numberDecimal accepts real numbers. Assume the EditText field is named: editTextBox, In Java code we could at run-time set the input method by issuing the command: editTextBox.setRawInputType( android.text.InputType.TYPE_CLASS_PHONE ) ;

13 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 13 Example2: Using android:inputType="textPassword" The keyboard displays all possible keys. Current character is briefly displayed for verification purposes. The current character is hidden and a heavy-dot is displayed. Example3: Using android:inputType="text Address" Soft keyboard favors characters commonly used in addresses such as

14 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 14 Example4: Using android:inputType= "phone" Soft keyboard displays the layout of a typical phone keypad plus additional non digit symbols such as: ( ). / Pause Wait # - +

15 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 15 Example5: Using android:inputType="time" Soft keyboard displays a numerical layout. Only digits and colon-char : can be used. When clicking on alphabetic choice ABC only character to make am and pm are allowed.

16 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 16 Example6: Using android:inputType="date" Soft keyboard displays a numerical layout. Only digits and date valid characters are allowed. Examples of valid dates are: 12/31/

17 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 17 Disable Soft Keyboarding on an EditText View Assume txtBox1 is an EditText box. To disable the action of the soft keyboard on an EditText you should set its input type to null, as indicated below: txtBox.setInputType( InputType.TYPE_NULL ); You may also try (deaf touch listener) txtBox.setOnTouchListener(new OnTouchListener() public boolean onTouch(View arg0, MotionEvent arg1) { // return true to consume the touch event without // allowing virtual keyboard to be called return true; } });

18 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 18 Close SoftKeyboard Window / Hide SoftKeyboard Once it has opened, you may close the virtual keyboard by tapping the hardware BackArrow key or issuing the following commands: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow (theEditTextField.getWindowToken(), 0);

19 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 19 TextWatcher Control Assume txtBox1 is an Editable box. A listener of the type onKeyListener could be used to follow the actions made by the hardware keyboard; however it will not properly work with the Virtual Keyboard. A solution to this problem is to attach to the Editable control a TextWatcher and let its methods be called when the Editable text is changed. The main methods of a TextWatcher are: public void afterTextChanged (Editable theWatchedText) public void beforeTextChanged ( … ) public void onTextChanged ( … )

20 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 20 Example 7: TextWatcher Demo EditText uses.addTextChangedListener IMF suggestions

21 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 21 Example 7: TextWatcher Demo <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffaabbcc" > <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10px" android:padding="4px" android:textStyle="bold" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10px" android:padding="4px" android:background="#ff0000ff" android:textStyle="bold" />

22 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 22 Example 7: TextWatcher Demo // demonstrate the use of a simple TEXTWATCHER control package cis493.keyboarding; … public class TextWatcherDemo extends Activity { EditText txtInput; TextView txtMsg; int keyCount = public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtMsg = (TextView)findViewById(R.id.txtMsg); txtInput = (EditText)findViewById(R.id.txtInput); txtInput.addTextChangedListener(new TextWatcher() { public void afterTextChanged (Editable theWatchedText) { String msg = "count: " + txtInput.getText().toString().length() + " " + theWatchedText.toString(); txtMsg.setText( msg ); } public void beforeTextChanged (CharSequence arg0, int arg1, int arg2, int arg3) { //Toast.makeText(getApplicationContext(), "BTC " + arg0, 1).show(); } public void onTextChanged (CharSequence arg0, int arg1, int arg2, int arg3) { //Toast.makeText(getApplicationContext(), "OTC " + arg0, 1).show(); } }); //addTextChangedListener } //onCreate }

23 7B. Android – UI – Hard & Soft Keyboard Hard & Soft Keyboard 23 Questions?