错误的setContentView [英] setContentView error
问题描述
我创建新布局命名splash.xml像下面,放在布局文件夹中。
结果
然后,我在下面创建
I created new layout named splash.xml like below and put in in layout folder.
Then I create a class named Splash.java like below
package com.example.buttonproj;
import android.R;
import android.app.Activity;
import android.os.Bundle;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash); //ERROR HERE
}
}
有是的setContentView(R.layout.splash)错误
。你能告诉我什么是错?
There is an error on setContentView(R.layout.splash)
. Can you tell me what is wrong?
推荐答案
删除行:
import android.R;
和验证您的XML文件没有任何错误。
and verify that your XML files don't have any errors.
Eclipse中有时进口这时候一个资源文件有编译错误,并自动更新您的家属(有<大骨节病>控制骨节病> + <大骨节病>移骨节病> + <大骨节病> 0 骨节病>的例)。然后,Eclipse试图读取它造成十分错误的R档产生破坏的处处的你参考 R上。*
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.*
查找根本原因(在Package Explorer窗口中,查找在 RES /
文件夹中的所有文件与红色的 X 的)和清洁您的项目(项目 - >清除)
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).
这篇关于错误的setContentView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!