Profile

Cover photo
Gildas Cuisinier
301 followers|196,777 views
AboutPostsPhotos+1'sReviews

Stream

Gildas Cuisinier

Shared publicly  - 
 
 
Android App Polishing: Customizing Soft Keyboard Action Button

With the release of Capitaine Train for Android[0], several people recently asked me how we implemented some of the tips & tricks available in the application (some of these tricks are barely visible but remember, I love details :p). In order to showcase some of the most interesting application bits of code, I thought it could be helpful to Android developers to start a small series of posts. Feel free to comment this article if you want me to describe something you found nice in the Capitaine Train application. 

A long long time ago, Android 1.6 introduced soft input methods. Soft input methods has many advantages over traditional hardware keyboards. It obviously requires less hardware and may help to build lighter devices. It also allow content-dependent keyboards. For instance, a keyboard may be different when typing a person name, an email address or a pin code.

By default, the Android framework bundles several constants you may use to control the keyboard that will appear. From the code perspective, this can be controlled with the android:inputType[1] XML attributes on TextView. You can also change the "Enter" button to display a text that better match its purpose. This can be done thanks to the android:imeOptions attribute (see [2] for an exhaustive list of all the possible values):

<EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:imeOptions="actionDone"
    android:inputType="textPassword" />

While a "Done" button can fit almost all purposes (log in form, sign up form, etc.) it is quite ambiguous and not really satisfying to my mind. At Capitaine Train we wanted the action button to better reflect the actual action it performs. As a consequence, when signing in, we wanted the button to display "Sign in" rather that "Done". Because that's what it does after all!

Android lets you customize the action button thanks to the android:imeActionLabel[3] and android:imeActionId[4] attributes (or their TextView#setActionLabelId(CharSequence, int)[5] Java equivalent). Using these methods basically consists on setting a label to the done button and a unique id used to identify the action. Here is what your XML layout should be look like:

<EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:imeActionId="@+id/action_sign_in"
    android:imeActionLabel="@string/sign_in_short"
    android:inputType="textPassword" />

The second part consists on catch all taps on the soft input keyboard action button made with the appropriate action id:

mEditText = (EditText) view.findViewById(R.id.password);
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
   @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == R.id.action_sign_in) {
            // Do sign in
            return true;
        }
        return false;
    }
});

#gde   #android  

[0]: https://play.google.com/store/apps/details?id=com.capitainetrain.android
[1]: http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
[2]: http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeOptions
[3]: http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeActionLabel
[4]: http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeActionId
[5]: http://developer.android.com/reference/android/widget/TextView.html#setImeActionLabel(java.lang.CharSequence,%20int)
1
benjamin fuentes's profile photo
 
more and more lazy ...
Add a comment...

Gildas Cuisinier

Shared publicly  - 
 
Le manque de neige a un impact sur le psychologique des enfants 
 ·  Translate
1
Add a comment...

Gildas Cuisinier

Shared publicly  - 
3
2
Pierre Neis's profile photoStéphanie MOALLIC's profile photo
Add a comment...
 
Mes photos de la conférence NAO du YaJUG
 ·  Translate
4
2
Michael Paquelier's profile photobenjamin fuentes's profile photoDaniel De Luca's profile photoPierre-Antoine Grégoire's profile photo
2 comments
 
Des enfants en effets, et beaucoup de grands enfants :)
 ·  Translate
Add a comment...
Have him in circles
301 people
Xavier Bourguignon's profile photo
Erwan Alliaume's profile photo
Baptiste Wicht's profile photo
Adrien Cominotto's profile photo

Gildas Cuisinier

Shared publicly  - 
 
Devoxx4Kids Arlon! Inscriptions ouvertes! 
 ·  Translate
1
1
Katrien Montulet's profile photo
Add a comment...

Gildas Cuisinier

Shared publicly  - 
 
 
Si vous êtes ou si vous connaissez des femmes développeurs (développeuses?) intéressées par Devoxx France (du 16 au 18 avril), ce formulaire est à remplir au plus vite.
 ·  Translate
1
Add a comment...
 
Instead of supporting Dropbox, Picasa, Flickr, etc. .. directly into the application, would it not be possible to give the possibility to extend the application?
The community could provide support for 500px, Koken, or otherwise.
5
Nick Felker's profile photo
 
There may be a way to take advantage of KitKat's file browser capabilities.
Add a comment...
 
I'am not able to install it.
The is is not compatible with my device (Nexus4 / CM 10.2), from Belgium.

What's the limitation? 
2
2
Brian Pyeatt's profile photoErick Newman's profile photoWim Vandekerckhove's profile photoBlack Maggot's profile photo
5 comments
 
My bad, I guess since it said it requires some 4.4 components , that it would need them to work fully, not just install. 
Add a comment...

Gildas Cuisinier

Shared publicly  - 
 
Premiers aménagements intérieurs ! #veranda
2
Guillaume Laforge's profile photoDenis De Messemacker's profile photoGildas Cuisinier's profile photoFabien Baligand's profile photo
5 comments
 
Très sympa ! C'est stylé ;)
 ·  Translate
Add a comment...

Gildas Cuisinier

Shared publicly  - 
 
Au secours ! 
 ·  Translate
1
Séb Nonoel's profile photo
 
Fuuurby .. le furby !! Tais toi !! Arrrgh
 ·  Translate
Add a comment...
People
Have him in circles
301 people
Xavier Bourguignon's profile photo
Erwan Alliaume's profile photo
Baptiste Wicht's profile photo
Adrien Cominotto's profile photo
Basic Information
Gender
Male
Work
Occupation
Consultant IT
Gildas Cuisinier's +1's are the things they like, agree with, or want to recommend.
DZone, Inc.
plus.google.com

Where Tech Professionals Learn IT

Skype - free IM &amp; video calls
market.android.com

Say “hello” to friends and family with an instant message, voice or video call on Skype for free. Join the millions of people using Skype to

NipTech Podcast » NipDev 0 – Single Page Applications
www.niptech.com

Podcast: Téléchargement. Dans ce tout premier numéro, @fXzo, @antoined et Seb nous parlent de Single Page Applications. Frameworks MVC Javas

Barcode Scanner
market.android.com

Scan barcodes on products then look up prices and reviews. You can also scan Data Matrix and QR Codes containing URLs, contact info, etc.Als

AngularJS — Superheroic JavaScript MVC Framework
angularjs.org

AngularJS is what HTML would have been, had it been designed for building web-apps. Declarative templates with data-binding, MVC, dependency

openjdk-osx-build
code.google.com

Build scripts and packages for OpenJDK 7 and 8 under OS/X Snow and Lion

Canon EOS 6D : le point de vue d’un amateur, propriétaire d’un 600D.
blog.reflex-photo.eu

Tout dépend de votre usage, dans de nombreux cas, un 600D, 650D ou pourquoi pas un EOS M sont d'excellents compagnons et l'utilisateur n'en

DashClock Widget
market.android.com

DashClock is a replacement lock screen clock widget for Android 4.2+. It also exposes additional status items called extensions. The widget

Le Touilleur Express » Blog Archive » Devoxx France 2012
www.touilleur-express.fr

Devoxx France 2012. 16 novembre 2011 3 affichages Pas de commentaire. Cher lecteur,. Je t&#39;annonce la naissance de Devoxx France 2012 ! P

Nom de domaine et hébergement Cloud - Certificat SSL - Gandi.net
www.gandi.net

GANDI Domaine est le premier bureau d'enregistrement de nom de domaine français (registrar) agréé par l'ICANN pour l'achat de noms de domain

Jean-Luc Lahaye : Album photos des années 80 !
maxtv80.over-blog.com

C'est qu'il était mignon quand même notre Jean-Luc national ! Un brin rebel…

lesjoiesducode
lesjoiesducode.tumblr.com

les_joies_du_code();. tu kiffes ce blog ? choisis ton arme ! Tweeter. t'as une idee ? fais peter ! quand je clique par erreur sur 'rebuild'

androidannotations
code.google.com

This project has moved to GitHub!

Angry Birds Space
market.android.com

The #1 mobile game of all time blasts off into space! ALL NEW ANGRY BIRDS GAME FROM ROVIO -- the #1 mobile game of all time blasts off into

gcBlog » Devoxx France, coté speaker
www.gcuisinier.net

Le début du rêveL’histoire a commencé à Anvers, durant une keynote à Devoxx de Stefan Janssens où il lance une bombe atomique. En collaborat

gcBlog » Présentation de xdt4j
www.gcuisinier.net

IntroductionChez mon client, nous avons eu un besoin particulier : celui de pouvoir étendre des archetypes Maven.Autrement dit, pouvoir crée

[Devoxx FR 2012] – Spring est mort. Vive Spring! | So@t blog
blog.soat.fr

[Devoxx FR 2012] – Spring est mort. Vive Spring! Gildas Cuisinier, fervent défenseur de Spring, nous a présenté les points qui font que Spri

Spring est mort, vive Spring
www.slideshare.net

Présentation au MarsJUG des nouveautés de Spring 3.1, et en particulier "Spring sans XML"

Mystique : thème | WP Themes - Thèmes WordPress en français
www.wpthemes.ch

Un jour, un visiteur m'envoie un mail pour me demander de traduire ce thème.... et c'est donc grâce à cette personne que je vous propose ce

Public - 8 months ago
reviewed 8 months ago
Très bon restaurant ! Je ne manque pas d'y aller quand je suis sur Bruxelles
Public - a year ago
reviewed a year ago
2 reviews
Map
Map
Map