setContentView error

I created new layout named splash.xml like below and put in in layout folder. Then I create a class named like below

   package com.example.buttonproj;
    import android.R;
    import android.os.Bundle;

    public class Splash extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        setContentView(R.layout.splash); //ERROR HERE



There is an error on setContentView(R.layout.splash). Can you tell me what is wrong?


Remove the line:

import android.R;

and verify that your XML files don't have any errors.

Eclipse sometimes imports this when a resource file has a compilation error and you automatically update your dependents (with Ctrl+Shift+O for example). Eclipse then tries to read the wrong R file which wreaks creates havoc everywhere you reference R.*

Find the root cause (in the Package Explorer window, look for any files in your res/ folder with the red x) and clean your project (Project -> Clean).

You can try removing the

import android.R;

and try importing the R from your project. Hope this helps.

Thanks for your answers.

I summarized the answer as below:

  1. sometimes eclipse refuseses to recognize your R. Try the full package name - com.example.nuttonproj.R.layout.splash – mihail


  1. removing the

import android.R;

The problem could be in the layout background: @drawable/abc. Does it exist in the drawable(s) folders?

  1. Never import android.R; it will include the system R components rather than user defined.

Need Your Help

error SIGABRT - Cannot load multiple arrays in my TableViewController

arrays swift uitableview

I am trying to load multiple food menu arrays into one TableViewController. The main menu displays 2 buttons, 1: breakfast menu 2: bakery menu. Every time I press on of them the simulator crashes and

Two "or" conditions for event?

jquery button click radio mouseup