Salut à tous!!
J'ai un problème avec mon listView . Il ne passe jamais dans la méthode onItemClick..
Voila le code du onCreate:
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
@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		/*
		setContentView(R.layout.loading);
 
 
		//Cree un thread pour la requete a la base
		FindMenuAroundMe fndAroundMe = new FindMenuAroundMe();
		fndAroundMe.OnFindAroundMeEnded(this); //donne le listener
		fndAroundMe.execute(); 
 
		*/
		setContentView(R.layout.activity_around_me);
 
		listMenuAroundMe = (ListView)findViewById(R.id.around_me_list_item);
 
 
		//Création de la ArrayList qui nous permettra de remplire la listView
        ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
 
        //On déclare la HashMap qui contiendra les informations pour un item
        HashMap<String, String> map;
 
 
       //getString permet de recuperer la valeur de la resource
        map = new HashMap<String, String>();
        map.put("id", "1");
        map.put("img", String.valueOf(R.drawable.logo) );
		map.put("restau_name", "Restzu");
		map.put("txt_ardoise","Plat\n20€");
		map.put("distance", "10 Km");
		map.put("pointer",String.valueOf(R.drawable.pointer));
		map.put("arrow",String.valueOf(R.drawable.next));
 
 
        listItem.add(map);
 
 
		HomeList adapter = new HomeList(this,listItem, R.layout.item_menu,
                new String[] {"img", "restau_name", "txt_ardoise", "distance", "pointer" , "arrow"}, 
                new int[] {R.id.img, R.id.restau_name, R.id.txt_ardoise,R.id.distance , R.id.img_pointer, R.id.img_arrow});
 
 
		listMenuAroundMe.setAdapter(adapter);
 
 
		listMenuAroundMe.setOnItemClickListener(this);
	}
Et la methode onItemClick
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
@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) 
	{
		Log.i("", "ID position = " +position);
 
		@SuppressWarnings("unchecked")
		HashMap<String, String> map = (HashMap<String, String>) listMenuAroundMe.getItemAtPosition(position);
 
		String id = map.get("id");
		Log.i("", "ID cocher = " + id);
		if(id != null)
		{
			// nouvelle activity
		}
 
	}
Merci