Wednesday 26 December 2012

Using the keyboard in Android


This tutorial will discuss the Android keyboard . The subject may seem simple and not very interesting but it is a very important issue in the development of applications, which adds a plus to your application and that is often overlooked by developers. So this article will include tips on how to improve the user experience of your application.

How to adjust the keyboard to your needs

In your application, the user will be required to enter some data types. In this case, it must facilitate the work of the user by displaying a keyboard according to the type of field to fill (email address, phone number, etc ...).
To do this in your " EditText ", simply specify the option android inputType . Here are the available values:
  • text (default): normal keyboard
  • textCapCharacters : Keyboard all caps
  • textCapWords : First letter automatically capitalized
  • textCapSentences : Phrase capitalized
  • textAutoCorrect : Enable automatic correction
  • textAutoComplete : Enable Autocorrect forced
  • textMultiLine : text on multiple lines
  • textNoSuggestions : No suggestion for correction
  • textUri : Entering a web url
  • textEmailAddress : Email Address
  • textEmailSubject : Subject of email
  • textShortMessage : Activates the smiley shortcut on the keyboard
  • textPersonName : Enter the name of a person (Showing speach to text on the bottom left of the keyboard)
  • textPostalAddress : Entering an address (Showing speach to text on the bottom left of the keyboard)
  • textPassword : Entering password
  • textVisiblePassword : Entering a password visible
  • textWebEditText : Text Web (activation shortcut tab and speach to text)
  • number / numberSigned / numberDecimal / phone / datetime / Date / time : Keypad
You can put multiple values ​​separated simply by "|" .

where is the next field?

When you have a keyboard that appears, you may desire it relates to the field after such a button " Next "appears instead of the button" newline ". Default value is " Next "and otherwise" Ok "if you are on the last field.
, but you can choose the option you want to display using the option android imeOptions and here are the different options available :
  • actionUnspecified : No specification, the editor will display what seems the most logical
  • actionNone : No specification.
  • actionGo : Displays the "Go"
  • actionSearch : Displays the "search"
  • actionSend : Displays the "send"
  • actionNext : displays the value "Next"
  • actionDone : displays the value "ok"
You can retrieve the action that has been selected to perform a specific action using setOnEditorActionListener ()and you will receive an event of type IME_ACTION_SEND when the button " send "is clicked

My keyboard hides my view

You may encounter a problem when the user clicks on EditText , this one is hidden by the keyboard or they are the fields below are no longer visible. To solve this problem you must play with two options:
  • In the corresponding part of your vision in the AndroidManifest.xml , you can add android: windowSoftInputMode = "adjustResize" which allows you to resize your view when the keyboard appears. For more details you can watch on the official website of android .
  • You can combine this option with the weight of different elements to your view: android: weight (you can see the tutorial on LinearLayout )

Conclusion

This tutorial ends here hoping it helped you to understand the operation of the keyboard in Android and how to facilitate the interaction between user and application.



No comments:

Post a Comment

Free Automatic Backlink