0

I've a little problem with android studio. Until yesterday I used Eclipse. But today I start to use Android studio. I write a simple layout without errors. Than in src/main/java I write this simple code:

public class MyActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(android.R.layout.activity_my); } } 

But I've an arror: "cannot resolve symbol activity_my"

According to me the layout isn't registrated in R.java. How can I resolve this problem? Thanks in advance :D

p.s. sorry for my bad english >.<

1
  • 1
    Change android.R.layout.activity_my to R.layout.activity_my and import R file Commented Sep 12, 2014 at 12:25

2 Answers 2

1

Use R and not android.R. Check that the imported R is your.package.name.R.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh my god, stupid problem -.-", sorry guys, and thanks
1

you should always use setContentView(R.layout.activity_my);.

so replace setContentView(android.R.layout.activity_my); with setContentView(R.layout.activity_my);

USE CTR + SHIFT + o to organize your import statements in eclipse.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.