Bonjour à tous,

après avoir fait plein de tests et écumés le net, je me permets de poster mon problème. Je cherche à faire un EditText avec un bouton qui me permet de chercher une location via l'API GoogleMaps. Le problème étant que lorsque je clique j'ai une erreur: la méthode onClick() renvoie la valeur Erreur: null j'ai pourtant testé avec un Toast la valeur de v.getId() qui est bien mon bouton en l'occurence.

Voici une partie de mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
 
	<LinearLayout
	    android:id="@+id/searchLayout"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:layout_alignRight="@+id/map"
	    android:orientation="horizontal" >
 
    <EditText
        android:id="@+id/searchLocation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:hint="@string/hint"
        android:inputType="text" />
 
    <Button
        android:id="@+id/bouton1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1.12"
        android:text="@string/button1" />
 
    </LinearLayout>
 
    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@id/searchLayout" />
 
</RelativeLayout>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
searchButton = (Button) findViewById(R.id.bouton1);
searchButton.setOnClickListener(this);
@Override
	public void onClick(View v) {
 
 
		try {
			if(v == searchButton){
 
				Geocoder geocoder = new Geocoder(MainActivity.this);
				search = recherche.getText().toString();
				try {
					List<Address> customAddress = geocoder.getFromLocationName(search, 4);
 
					if(customAddress.size() > 0){
 
						double latitude = customAddress.get(0).getLatitude();
						double longitude = customAddress.get(0).getLongitude();
 
 
						map.addMarker(new MarkerOptions()
							.position(new LatLng(latitude, longitude))
							.title("Résultat de la recherche")
							.snippet(search)
								);
 
					} else {
 
						Toast.makeText(MainActivity.this, "La recherche n'a pas abouti", Toast.LENGTH_LONG).show();
					}
				} catch (IOException e) {
 
					e.printStackTrace();
				}
			} else {
 
				Toast.makeText(MainActivity.this, "Merci de saisir une location valide", Toast.LENGTH_SHORT).show();
			}
 
 
 
		}
 
		catch(Exception O) {
 
				Toast.makeText(MainActivity.this, "Erreur: " + O.getMessage(), Toast.LENGTH_LONG).show();
		}
 
 
	}
L'interface OnClicklistener est bien implémentée ainsi que la méthode onClick() inhérente.
Est ce que le fait que fait que l'EditText et le bouton soient dans un LinearLayout compris dans le RelativeLayout peut être un soucis?
Si quelqu'un a un avis sur mon problème...
Merci d'avance.