Bonjour
Je viens vers vous car j'ai un petit soucis au niveau d'une de mes liste , dans cette dernière la première ligne correspond aux " titres" des différentes colonnes. j'ai utilise un OnItemclickListener sur cette liste afin d'afficher les fiches adhérents qui correspondent mais lorsque je clique sans le vouloir sur la première ligne, mon application crash ( logique elle ne renvoie a rien ).
Voici ma fonction d'affichage d’adhérent :
Et la fonction onclick qui l'utilise :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 protected void AfficherActFicheAdherent(String IdAdherent) { Intent IntentAfficherAdh = new Intent(Act_ListeAdherents.this,Act_FicheAdherent.class); // demarrer activity if (IntentAfficherAdh != null) { IntentAfficherAdh.putExtra("IdAdherent",IdAdherent ); Log.d("*** INTENT: ", "" + IntentAfficherAdh.getExtras().get("IdAdherent")); startActivity(IntentAfficherAdh); } }
Ce que je voudrai faire : que le Onclick ne prenne pas en compte cette première ligne de "titre" pour que le crash ne se reproduise plus.
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 LV_Liste.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { view.setSelected(true); String nom = (String) "" + parent.getSelectedItemId(); String item = (String) "" + parent.getItemIdAtPosition(position); LinearLayout LA_DETAILS = (LinearLayout) view.findViewById(R.id.LA_DETAILS); TextView TV_ID = (TextView) view.findViewById(R.id.ID); String IdAdherent = TV_ID.getText().toString(); /*Toast.makeText(getApplicationContext(), "Click ListItem Number " + position + " " + nom + " " + item + " " + TV_ID.getText().toString(), Toast.LENGTH_SHORT) .show(); **/ if (LA_DETAILS.getVisibility() == View.VISIBLE) { LA_DETAILS.setVisibility(View.GONE); LA_DETAILS.setBackgroundColor(255); } else { LA_DETAILS.setVisibility(View.VISIBLE); } AfficherActFicheAdherent(IdAdherent); } });
Merci beaucoup à ceux qui prendront la peine de me répondre
Partager