2010-09-03 4 views
0

J'ai une mise en page d'activité Android très simple comme ceci:ImageView objet toujours nul

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <ImageView id="@+id/blaimg" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 
</LinearLayout> 

Maintenant, quand je fais ce qui suit de onOptionsItemSelected:

ImageView imgView = (ImageView)findViewById(R.id.blaimg); 

le contenu de imgView est toujours nul! Qu'est-ce que je fais de mal?

Merci!

Répondre

0

changer votre déclaration de ImageView à ::

<ImageView android:id="@+id/blaimg"  
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 
+0

Haha je devais continuer à regarder jusqu'à ce que je voyais la différence. id -> android: id –

+0

Ah pour l'amour de pete, qui avait en effet tout le problème! Bon sang. Eh bien merci beaucoup! Je pense que j'ai regardé au moins 2 heures pour voir ce qui n'allait pas. –

Questions connexes