Thanks for your answer Bart
I've done this:
public class Xml extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.liste);
}
public static ArrayList<ArrayList> renvoi_liste_recette_xml(){
ArrayList<ArrayList> aTableRetour = new ArrayList<ArrayList>();
URL myURL = null;
try {
myURL = new URL("http://benji.roullet.free.fr/recette.xml");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance
();
DocumentBuilder constructeur = null;
try {
constructeur = fabrique.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document document = null;
try {
document = constructeur.parse(myURL.openStream());
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Element racine = document.getDocumentElement();
NodeList liste = racine.getElementsByTagName("recette");
for(int i=0; i<liste.getLength(); i++){
ArrayList<String> aTableauTmp = new ArrayList<String>();
Element E1= (Element) liste.item(i);
//aTableRetour[i]= "";
aTableauTmp.add(E1.getAttribute("nom"));
aTableRetour.add(aTableauTmp);
}
return aTableRetour;
}
ArrayList listeRecette = renvoi_liste_recette_xml();
ListView mRecetteList = (ListView) findViewById(android.R.id.list);
SimpleAdapter mSchedule = new SimpleAdapter(this, listeRecette ,
R.layout.item,
new String[] {"titre"}, new int[] { R.id.titre});
}
And the application have an error which i can't see with the debug
mode.
Do you see anything wrong ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---