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
   | 	NodeList nl = doc.getElementsByTagName(KEY_ITEM);
		// looping through all item nodes <item>
		for (int i = 0; i < nl.getLength(); i++) {
 
			// creating new HashMap
	 HashMap<String, String>  map = new HashMap<String, String>();
			Element e = (Element) nl.item(i);
			// adding each child node to HashMap key => value
			map.put(KEY_ID, parser.getValue(e, KEY_ID));
			map.put(KEY_TITRE, parser.getValue(e, KEY_TITRE));
			map.put(KEY_CHAPEAU, parser.getValue(e, KEY_CHAPEAU));
			map.put(KEY_TEXTE, parser.getValue(e, KEY_TEXTE));
			// adding HashList to ArrayList
			menuItems.add(map);
 
		}
 
 
		// Adding menuItems to ListView
		ListAdapter adapter = new SimpleAdapter(this, menuItems,
				R.layout.actualie_item,
				new String[] { KEY_TITRE, KEY_CHAPEAU}, new int[] {
						R.id.titre, R.id.chapeau});
 
		setListAdapter(adapter);
 
		// selecting single ListView item
		final ListView lv = getListView();
 
		lv.setOnItemClickListener(new OnItemClickListener() {
 
 
 
 
			@SuppressWarnings("unchecked")
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
 
 
				// getting values from selected ListItem
				String titre = ((TextView) view.findViewById(R.id.titre)).getText().toString();
				String chapeau = ((TextView) view.findViewById(R.id.chapeau)).getText().toString();
 
				// Starting new intent
				Intent in = new Intent(getApplicationContext(), actualites_text.class);
 
				in.putExtra(KEY_TITRE, titre);
				in.putExtra(KEY_CHAPEAU, chapeau);
 
 
 
 
 
				startActivity(in);
 
			}
		});
	}} | 
Partager