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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
public class List extends Activity {
private ListView maListViewPerso;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.liste);
maListViewPerso = (ListView) findViewById(R.id.listviewperso);
ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
map = new HashMap<String, String>();
map.put("titre", "compte");
listItem.add(map);
map = new HashMap<String, String>();
map.put("titre", "opération");
map.put("description", "les opérations ");
listItem.add(map);
map = new HashMap<String, String>();
map.put("titre", "suvui ");
map.put("description", "suvui de compte ");
listItem.add(map);
SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.affichageitem,
new String[] {"img", "titre", "description"}, new int[] {R.id.img, R.id.titre, R.id.description});
maListViewPerso.setAdapter(mSchedule);
maListViewPerso.setOnItemClickListener(new OnItemClickListener() {
@Override
@SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
HashMap<String, String> map = (HashMap<String, String>) maListViewPerso.getItemAtPosition(position);
AlertDialog.Builder adb = new AlertDialog.Builder(Tutoriel5_Android.this);
adb.setTitle("Sélection Item");
adb.setMessage("Votre choix : "+map.get("titre"));
adb.setPositiveButton("Ok", null);
adb.show();
}
});
}
} |
Partager