Reputation: 61
I need to change the background color from a RelativeLayout programmatically.
In the XML file I have done this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/milayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/negro"
android:orientation="horizontal"
android:padding="5dip"
>
Then on the activity file, I am trying to declare the layout to change later the background color of the RelativeLayout, as I have seen in other posts here in SO.
RelativeLayout MyLayout = (RelativeLayout) findViewById(R.layout.milayout);
But I get there an error: "Create field milayout in type 'layout'"
What am I doing wrong?
Upvotes: 0
Views: 62
Reputation: 10859
look at your code
RelativeLayout MyLayout = (RelativeLayout) findViewById(R.layout.milayout);
change to this
RelativeLayout myLayout = (RelativeLayout) findViewById(R.id.milayout);
Upvotes: 1