Android setContentView无法识别.xml页面

Android setContentView无法识别.xml页面,android,xml,splash-screen,Android,Xml,Splash Screen,我在我的应用程序的开头添加了一个起始页,持续5秒,但当我这样做时,它在setContentView(R.layout.splash)旁边放了一个小“x”;它有一个xml文件,所以我不知道为什么它不工作。我加粗的那一行就是我遇到麻烦的那一行 package com.jslsoftware; import android.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle;

我在我的应用程序的开头添加了一个起始页,持续5秒,但当我这样做时,它在setContentView(R.layout.splash)旁边放了一个小“x”;它有一个xml文件,所以我不知道为什么它不工作。我加粗的那一行就是我遇到麻烦的那一行

package com.jslsoftware;

import android.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class ILearnSignActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread logoTimer = new Thread(){
    public void run(){
        try{
            sleep(5000);
            Intent menuIntent = new Intent("com.jslsoftware.MENU");
            startActivity(menuIntent);              
        }           
        finally{
            finish();               
        }
    }        
    };
    logoTimer.start();          
   }
}

检查您的导入,它不应该是

android.R;
但是


检查您的导入,它不应该是

android.R;
但是


检查资源文件夹中是否存在任何错误,如drawable、string和layout等。如果存在错误,android将无法创建gen文件夹。还可以查看import android.R.

查看资源文件夹中是否存在任何错误,如drawable、string和layout等。如果存在错误,android将无法创建gen文件夹。如果您使用Eclipse,还可以查看importandroid.R.

Scott:

在文件树中选择项目,然后转到顶部的项目菜单->清理


这通常有助于重新组装R文件并将其与项目重新链接

Scott,如果您使用Eclipse:

在文件树中选择项目,然后转到顶部的项目菜单->清理


这通常有助于重新组装R文件并将其与项目重新链接

我也有同样的问题。我删除了这个:

 import android.R;
取而代之的是

 import com.(ur package).R;

我也有同样的问题。我删除了这个:

 import android.R;
取而代之的是

 import com.(ur package).R;

它成功了。

构建>>清洁项目


重新启动Android Studio/Eclipse

构建>>清理项目

重新启动Android Studio/Eclipse