Skip to content Skip to sidebar Skip to footer

Error :activity_main Can Not Be Resolved Or Not A Field

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

Solution 1:

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`.

Post a Comment for "Error :activity_main Can Not Be Resolved Or Not A Field"