Bonjour
J'ai codé une listView qui affiche une liste de couleur. L'affichage se passe sans problème mais impossible de récupérer la couleur sélectionnée.
couleur est un tableau de String
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 ArrayAdapter<String> adapterColor = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, couleur); ListView listColor = (ListView)dialogColor.findViewById(R.id.ListView01); listColor.setAdapter(adapterColor); listColor.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long arg3) { // TODO Auto-generated method stub Toast toast = Toast.makeText(getApplicationContext(),couleur[position], Toast.LENGTH_LONG); toast.show(); } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } });
Une idée ?
mc
Partager