安卓错误:无法解析活动_main或不是字段
获得上述错误followed this
但没有找到解决办法。检查了我的资源文件,但没有使用建议我可用于此的解决方案。这里是活动的主视图。xml 和
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent" >
<Button
安卓:id="@+id/button1"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignParentTop="true"
安卓:layout_centerHorizontal="true"
安卓:layout_marginTop="87dp"
安卓:text="Button" />
<Button
安卓:id="@+id/button2"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/button1"
安卓:layout_centerVertical="true"
安卓:text="Button2" />
<Button
安卓:id="@+id/button3"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/button2"
安卓:layout_below="@+id/button2"
安卓:layout_marginTop="52dp"
安卓:text="Button" />
</RelativeLayout>
# 1 楼答案
改变
到
From the Docs代表
setContentView()
如果查看
R.java
文件夹中的gen
,则会发现不同的类R.id
是指id
你给出的View
R.layout
是指layout
文件,您可以创建.
setContentVieweither takes a
布局or a
视图. Not an
idof a
视图`