getText dans EditableText view
Bonjour,
j'ai une barre EditableText où je fais inscrire du texte à l'utilisateur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
search_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (search_bar.hasSelection()) {
RechercheGoogleMaps(search_bar.getText());
}
else {
Toast.makeText(AccueilActivity.this,
"Il faut d'abord sélectionner le texte.",
Toast.LENGTH_SHORT).show();
}
}
}); |
et un bouton recherche qui valide le texte inscrit et qui une recherche google maps. Le truc c'est qu'il faut " sélectionner " le texte de la barre avant d'appuyer sur " ok ". Moi je veux que le texte soit directement pris en compte, sans forcément " selectionner " le texte.
Merci !
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <RelativeLayout
android:id="@+id/widget118"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<EditText
android:id="@+id/search_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Tapez-ici votre recherche"
android:textSize="14sp"
android:typeface="serif"
android:textStyle="bold"
android:layout_alignTop="@+id/search_button"
android:layout_alignParentLeft="true"
android:selectAllOnFocus="true"
>
</EditText>
<Button
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:typeface="serif"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
>
</Button>
</RelativeLayout> |