views:

35

answers:

1

Hi,

I have a very simple Android activity layout like this:

<?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>

Now when I (from onOptionsItemSelected) do the following:

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

the contents of imgView is allways null! What am I doing wrong?

(thanks!)

A: 

change your ImageView declaration to::

<ImageView android:id="@+id/blaimg"     
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
Jorgesys
Haha I had to keep looking till I saw the difference. id -> android:id
Biff MaGriff
Ah for pete's sake, that indeed whas the whole problem! Dammit. Well thanks a lot! I think I've been looking at least 2 hours to see what was wrong.
Folkert van Heusden