0

getting above error .followed this

but didn't find solution.checked my resource file and all but no use suggest me sutable solution for this.here placing the activity_main.xml and problem

<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>
Community
  • 1
  • 1

1 Answers1

0

Change

setContentView(R.id.activity_main);

to

setContentView(R.layout.activity_main);

From the Docs for setContentView()

Set the activity content from a layout resource. The resource will be inflated, adding all top-level views to the activity.

If you look in R.java in the gen folder, there are different classes. R.id is for an id that you give a certain View. R.layout is for a layout file that you create.setContentVieweither takes alayoutor aView. Not anidof aView`.

codeMagic
  • 44,549
  • 13
  • 77
  • 93