0
我需要以编程方式从RelativeLayout更改背景色。如何识别活动中的RelativeLayout
在XML文件中我已经做到了这一点:
<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"
>
然后在活动文件,我想声明的布局改变以后的RelativeLayout的背景颜色,就像我在其他帖子看到在这里。
RelativeLayout MyLayout = (RelativeLayout) findViewById(R.layout.milayout);
但我到达那里的错误:“在类型创建领域milayout‘布局’”
我在做什么错?
谢谢你,但现在的错误在于对findViewById,它说:“创建方法findViewById(int)的” – novato 2014-12-07 00:34:56
发表您的活动课,让我从顶部的OnCreate @诺瓦托看 – Elltz 2014-12-07 00:37:13
没有必要Elitz,正确的代码是:RelativeLayout myLayout =(RelativeLayout)itemView.findViewById(R.id.milayout);现在它的工作原理,谢谢你在任何情况下 – novato 2014-12-07 00:42:35