简体   繁体   English

(R.layout.splash); 飞溅无法解决或不是字段

[英](R.layout.splash); splash cannot be resolved or is not a field

I'm in the middle of making my first Android app on eclipse, and I am running into a problem. 我正准备在eclipse上制作我的第一个Android应用程序,并且遇到了问题。 Basically I'm getting a splash cannot be resolved or is not a field error. 基本上,我无法解决启动错误或不是字段错误。 The code was working 10 min ago. 该代码在10分钟前有效。 The following link is to this project in my dropbox. 以下链接是我的保管箱中该项目的链接。 That away if you want, you can test some theories out on it. 如果需要的话,您可以测试一些理论。 https://www.dropbox.com/sh/1sg8p9uvjbolqxx/AADcMiPWB_JVEysb01B_hUtBa The following is a copy of the code the Java side. https://www.dropbox.com/sh/1sg8p9uvjbolqxx/AADcMiPWB_JVEysb01B_hUtBa以下是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 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: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>

Verify if you dont have erros in the layout splash file. 验证布局初始文件中是否没有错误。 Probably the project is not building the R because you have an error in some XML file. 可能是该项目未构建R,因为您在某些XML文件中存在错误。 Try to find it and clear the project. 尝试找到它并清除项目。

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);
}

I figured it out thanks to you guys. 我想通了,谢谢你们。 When I was undoing the code you had me put in, I found out the following was messing up the layout read. 当我撤消输入的代码时,我发现以下内容弄乱了所读取的布局。 import android.R; 导入android.R;

Thanks for everyones help. 谢谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM