0

超越错误。跟着这个

但没有找到解决方案。检查了我的资源文件,但没有任何用处建议我为此提供合适的解决方案。这里放置 activity_main.xml 和问题

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="87dp"
    android:text="Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button1"
    android:layout_centerVertical="true"
    android:text="Button2" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button2"
    android:layout_below="@+id/button2"
    android:layout_marginTop="52dp"
    android:text="Button" />

</RelativeLayout>
4

1 回答 1

0

改变

setContentView(R.id.activity_main);

setContentView(R.layout.activity_main);

来自文档setContentView()

从布局资源中设置活动内容。资源将被膨胀,将所有顶级视图添加到活动中。

如果您在文件夹中查看R.javagen则有不同的类。R.id是为了一个id你给的某个ViewR.layout用于layout您创建的文件.setContentView either takes alayout or aView . Not anid of aView`。

于 2013-08-17T14:59:51.733 回答