【问题标题】:Simple Splash Screen简单的启动画面
【发布时间】:2010-01-13 20:37:34
【问题描述】:

我正在尝试按照我找到的一个简单的闪屏示例进行操作。但我什至无法编译。

首先这是示例here的来源。

我正在尝试输入一个适合我的程序的表格。

我在 Eclipse 中为这个闪屏创建了一个类

com.ePN.ePNMobileAndroid.ePNSplash

这是我当前的 main.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:id="@+id/splashscreen" android:layout_width="wrap_content"
          android:layout_height="fill_parent" android:src="@drawable/com.ePN.ePNMobileAndroid.splash"
          android:layout_gravity="center"/>
     <TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content" android:text="Hello World, splash"/>
</LinearLayout> 

还有课程本身

package com.ePN.ePNMobileAndroid;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView; 

public class ePNSplash extends Activity {
    private static final int STOPSPLASH = 0;
    //time in milliseconds
    private static final long SPLASHTIME = 3000;
    
    private ImageView splash;
    
    //handler for splash screen
    private Handler splashHandler = new Handler() {
         /* (non-Javadoc)
          * @see android.os.Handler#handleMessage(android.os.Message)
          */
         @Override
         public void handleMessage(Message msg) {
              switch (msg.what) {
              case STOPSPLASH:
                   //remove SplashScreen from view
                  splash.setVisibility(View.GONE);
                   break;
              }
              super.handleMessage(msg);
         }
    };
    
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle icicle) {
       super.onCreate(icicle);
       setContentView(R.layout.main);
              splash = (ImageView) findViewById(R.id.splashscreen);
              Message msg = new Message();
              msg.what = STOPSPLASH;
              splashHandler.sendMessageDelayed(msg, SPLASHTIME);
   } 
}

XML 错误:

找不到与给定名称匹配的资源(在具有值的 src '@drawable/com.ePN.ePNMobileAndroid.splash')

我已经尝试了所有我能想到的方法来修改android:src,但它不起作用。

该类出错,因为它无法解析 find by id 行中的 r_id.splashscreen

这对我来说都是希腊文,应该如何修改这个琐碎的 xml 和/或 java 文件以使其工作?

【问题讨论】:

  • 你试过@drawable/com.ePN.ePNMobileAndroid.ePNSplash吗?
  • 相同的结果,除了它列出了“@drawable/com.ePN.ePNMobileAndroid.ePNSplash”

标签: android splash-screen


【解决方案1】:

android:src="@drawable/com.ePN.ePNMobileAndroid.splash" 中,你想在这个 ImageView 中显示什么?这需要引用您的 res/drawable 目录中的某些内容。例如,如果您在 res/drawable 中有一个名为 my_splash_image.png 的文件,那么 XML 属性将为 android:src="@drawable/my_splash_image"。无论您尝试在该属性中使用该包命名做什么都行不通。

查看您正在使用的示例,他们似乎有一个他们正在使用的 res/drawable/splash.png 文件,但他们没有包含在他们的论坛帖子中。

【讨论】:

  • 是的,事实证明我没有您指出的图像。 TY
猜你喜欢
  • 2020-09-20
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多