Error At Setcontentviewr.layout.main
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up setContentView(R.layout.main); Gives error from start up vote -1 down vote favorite I'm just starting to develop with android, and a followed a tutorial on google to get everything set up. I'm using eclipse and I have both the android sdk and the eclipse plugin installed, but when I create a new Android Project, I get an error on this line from the start. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } It Says that the "R" in "R.layout.main" does not exist. Is there class that i need to create or import? I'm really confused because i have thoroughly searched and cannot find anyone else with this issue. android share|improve this question asked Jun 5 '12 at 21:03 Mike 20116 You need to import your.package.name.R –K-ballo Jun 5 '12 at 21:05 Where can I find this file? –Mike Jun 5 '12 at 21:12 It's autogenerated, check the gen folder for your project. –K-ballo Jun 5 '12 at 21:13 Nothing is in there. –Mike Jun 5 '12 at 21:13 That usually indicates that there is an error in one of your resources, and the project isn't building correctly. Check your resources for errors. –K-ballo Jun 5 '12 at 21:14 add a comment| 7 Answers 7 active oldest votes up vote 3 down vote accepted this is quite a common mistake . make sure that at the top of your java file of the activity , the import is not of android.R.layout (or whatever) ,since it should import the R of your own app (which is inside the gen folder). if you still have problems with that , try to delete the gen folder , make sure the layout file is ok (meaning it's a correct android layout file, without any mistakes), make sure all of the resources (all images, sounds , xml files , all that are in /res) have only the legal characters in their files names (which me
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack http://stackoverflow.com/questions/10904925/setcontentviewr-layout-main-gives-error-from-start Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up setContentView(R.layout.Main); Main cannot be resolved or is not a field up vote 3 down vote favorite This is a simple program for beginning (simple http://stackoverflow.com/questions/12715221/setcontentviewr-layout-main-main-cannot-be-resolved-or-is-not-a-field for you, not for me) eclipse. I want to change a text by clicking on a button, but it's not working. Here is the code: package com.example.androidcourse; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.R.layout; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.Main); Button btn = (Button) findViewById(R.id.but_action); final TextView text = (TextView) findViewById(R.id.txt_caption); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { text.setText("New bingo..."); } }); } } android android-widget javadoc share|improve this question edited Oct 4 '12 at 12:05 Anthony Grist 31k33963 asked Oct 3 '12 at 19:11 max 92831227 add a comment| 4 Answers 4 active oldest votes up vote 8 down vote accepted First just build your project. If it will not work, then delete from imports android.R.layout and use layout from your package. share|improve this answer edited May 3 at 17:
here for a quick overview of the site Help Center Detailed answers http://stackoverflow.com/questions/9550507/setcontentviewr-layout-main-main-is-showing-error to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack error at Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up setContentView(R.layout.main); main is showing error up vote 1 down vote favorite Here is coding package todo.list; import android.R; import android.R.layout; import android.app.Activity; import android.os.Bundle; import error at setcontentviewr.layout.main android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class TodolistActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnSave = (Button)this.findViewById(R.id.button1); final EditText txtEdit=(EditText)this.findViewById(R.id.edit); btnSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String message = txtEdit.getText().toString(); Toast.makeText(TodolistActivity.this, message, 20).show(); } }); } } I import all classes but still its showing an error with connection to my main.xml setContentView(R.layout.main); main is showing error MAIN CAN NOT BE RESOLVED OR IS NOT A FIELD android share|improve this question edited Mar 24 '13 at 2:54 Sergey Kuryanov 4,0691640 asked Mar 3 '12 at 22:41 Furqan Khyraj 6115 add a comment| 5 Answers 5 active oldest votes up vote 2 down vote Delete these lines: import android.R; import android.R.layout; If using Eclipse, hit Command(Cntrl)+Shift+O after, or replace with import todo.list.R share|improve this ans