(R.布局、飞溅);飞溅无法解决或不是字段 我正准备在Eclipse上制作我的第一个Android应用程序,我遇到了一个问题。基本上,我得到的飞溅无法解决或不是一个领域的错误。 代码在10分钟前就开始工作了。以下链接指向我的dropbox中的此项目。如果你愿意的话,你可以用它来测试一些理论。 下面是Java端代码的副本 public class Splash extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.splash); Thread timer = new Thread() { public void run() { try{ sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } finally { Intent openStartingPoint = new Intent("com.techreviewsandhelp.carteretcountyhistoryguide.MAINACTIVITY"); startActivity(openStartingPoint); } } }; timer.start(); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); finish(); } }
XML(R.布局、飞溅);飞溅无法解决或不是字段 我正准备在Eclipse上制作我的第一个Android应用程序,我遇到了一个问题。基本上,我得到的飞溅无法解决或不是一个领域的错误。 代码在10分钟前就开始工作了。以下链接指向我的dropbox中的此项目。如果你愿意的话,你可以用它来测试一些理论。 下面是Java端代码的副本 public class Splash extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.splash); Thread timer = new Thread() { public void run() { try{ sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } finally { Intent openStartingPoint = new Intent("com.techreviewsandhelp.carteretcountyhistoryguide.MAINACTIVITY"); startActivity(openStartingPoint); } } }; timer.start(); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); finish(); } },java,android,eclipse,xcode,splash-screen,Java,Android,Eclipse,Xcode,Splash Screen,XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android.com/apk/res/android"; android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="schemas.android.com/apk/res/android";
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/splash">
<ImageView android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/trh" />
</LinearLayout>
验证布局启动文件中是否存在错误。可能项目没有构建R,因为您在某个XML文件中有一个错误。试着找到它并清理项目。多亏了你们,我才弄明白。当我撤销你让我输入的代码时,我发现下面的内容把阅读的布局搞乱了。
Try to replace this code:
import android.os.Handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent openStartingPoint = new Intent(Splash.this,MAINACTIVITY.class);
startActivity(openStartingPoint);
}
},5000);
}
导入android.R
谢谢大家的帮助。顺便说一句,我确实在xml中添加了splash ID。这是那里的代码。尝试清理您的项目,可能是您弄乱了xml文件。xml文件中有错误吗?如果有
导入android.R
,则将其删除。如果在闪屏中显示一些图像,请确保符合android标准,即图像名称不应包含数字和大写字母,如果它包含可能损坏您的R文件的内容,请检查我在其他任何地方都没有任何错误。事实上,我在splash.xml上甚至没有任何警告。我只是在原始帖子中添加了一个dropbox链接。这增加了12个错误。splash错误仍然存在,现在它有以下内容。MAINACTIVITY无法解析为类型处理程序无法解析为类型语法错误第34行,那么其余区域都是已经存在的语法错误。我刚刚在原始帖子中添加了dropbox链接。