georgesleyeti Posted March 29, 2011 Share Posted March 29, 2011 Bonjour, je suis bloqué depuis un petit moment sur le problème suivant : J'ai un fichier main.xml qui contient toute la structure de mon UI. Dans cette structure, se trouve une ScrollView : <ScrollView android:id="@+id/scrollview1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> Dans mon code, je souhaite créer un objet ScrollView qui reprend cette structure, je fais donc un : ScrollView scrollV = (ScrollView) findViewById(R.id.scrollview1); Mais en débuguant, je remarque que mon objet scrollV est null, car R.id.scrollview1 a apparemment un type inconnu (>Unkown type "me.georgesleyeti.androidapp.R$id"). Est-ce que je fais quelque chose de faux ? Merci d'avance. Link to comment Share on other sites More sharing options...
chpil Posted March 29, 2011 Share Posted March 29, 2011 Si scrollV est null, c'est que findViewById ne le trouve pas dans la structure de la vue. Appelle-tu bien cette méthode dans le bon contexte (l'Activity/la View qui correspond à ton main.xml) ? Link to comment Share on other sites More sharing options...
georgesleyeti Posted March 29, 2011 Author Share Posted March 29, 2011 Si scrollV est null, c'est que findViewById ne le trouve pas dans la structure de la vue. Appelle-tu bien cette méthode dans le bon contexte (l'Activity/la View qui correspond à ton main.xml) ? Hmmpf ,... merci, j'viens de remarquer que j'avais effacé le setContentView(R.layout.main); ça marche mieux en le remettant :o Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.