我在启动应用之前尝试使用启动功能。图像名称匹配并且不显示xml文件和java文件中的任何错误。但是项目显示错误:找不到与给定名称匹配的资源 这些是splash.java和splash.xml代码: splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/splash"
android:layout_gravity="center"/>
</LinearLayout>
splash.java:
package com.splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
int secondsDelayed = 1;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(Splash.this, menu.class));
finish();
}
}, secondsDelayed * 1000);
}
}
答案 0 :(得分:0)
我在我的应用程序中也发现了这个错误。在我的应用程序中,我通过在drawables的所有文件夹中制作png图像的副本来解决我的问题,即drawable-ldpi,drawable-mdpi,drawable-hdpi,drawable-xhdpi。这在我的应用程序中正常工作。希望这能解决你的问题。