onEditorAction : valeur de retour
Bonjour, je reviens vers vous car je ne comprend pas vraiment le paramètre de retour de la méthode onEditorAction.
Celle-ci retourne un booléen, mais je ne sais pas comment choisir s'il faut retourner vrai ou faux.
Code:
1 2 3 4 5 6 7 8 9 10 11
| public abstract boolean onEditorAction (TextView v, int actionId, KeyEvent event)
Called when an action is being performed.
Parameters
- v : The view that was clicked.
- actionId : Identifier of the action. This will be either the identifier you supplied, or EditorInfo.IME_NULL if being called due to the enter key being pressed.
- event : If triggered by an enter key, this is the event; otherwise, this is null.
Returns
- boolean : Return true if you have consumed the action, else false. |
Je redéfini cette méthode pour affecter un OnEditorActionListener à un TextView.
Pour l'instant, j'ai remarqué que lorsqu'on retourne false, le clavier se masque tout seul, contrairment à un return true.
Par ailleurs, j'ai aussi remarqué que lorsque je retourne false, et que j'affecte l'option IME actionSearch (voir ci-dessous) à mon EditText, l'application exécute deux fois le OnEditorActionListener.
Code:
1 2 3 4 5 6 7 8
| <EditText
android:id="@+id/rechercheTexte"
android:inputType="textNoSuggestions"
android:imeOptions="actionSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp" >
</EditText> |
A quoi correspond donc ce booléen ? Quel est son effet ?