Hi @all,

I wanted to create an activity where the top of the activity is
dynamic and depends on a state change of the application (pressing a
button).

Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:weightSum="2">
  <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <include android:id="@+id/included_main_screen" layout="@layout/
main_screen" />
        <include android:id="@+id/included_onbuttonclick_screen"
layout="@layout/onbuttonclick_screen" />
  </LinearLayout>
  <LinearLayout
        android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" >
        <Button ... />
  </LinearLayout>
</LinearLayout>

Both includes are RelativeLayout with id="main_screen" or
id="onbuttonclick_screen". The idea was to play with VISIBLE and
INVISIBLE attributes. But to my surprise the result is a
NullPointerException.

When I try to load the RelativeLayout (here in the example is a View)
in the onCreate method of the activity
View mMainScreen = this.findViewById(R.id.main_screen);
View mOnButtonClickScreen=
this.findViewById(R.id.onbuttonclick_screen);
it is always null. The application crashes with a null pointer
exception if I press the button and try to get the second xml file
into the foreground.
mMainScreen.setVisibility(View.INVISIBLE);
mOnButtonClickScreen.setVisibility(View.VISIBLE);

Does anybody see the reason why this can not work? I played around but
was not able to get rid of that findViewById returns always a null
pointer. The main_screen is shown correctly. First pressing the button
leads to the crash - unfortunately!

Does anybody have another idea, which is easy to handle?

Thank you in advance.
T-Droid

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

Reply via email to