简单的初始屏幕

简单的初始屏幕

问题描述:

我想跟着我找到的一个简单的初始屏幕示例。但我无法得到它甚至编译。简单的初始屏幕

首先,这是该示例的源:

http://www.anddev.org/simple_splash_screen-t811.html

我试图把在成会为我的程序工作的形式。

我创建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的方法,但它不起作用。

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

这对我来说都是希腊语,应该如何修改这个微不足道的xml和/或java文件来实现这个功能?

感谢名单

朱利安

+0

你试过'@ drawable/com.ePN.ePNMobileAndroid.ePNSplash'吗? – 2010-01-13 20:40:35

+0

相同的结果,除了它列出“@ drawable/com.ePN.ePNMobileAndroid.ePNSplash” – Bodger 2010-01-13 20:43:34

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

看着你正在使用的例子,它看起来像他们有一个res/drawable/splash.png文件,他们正在使用,他们没有包括在他们的论坛帖子。

+0

是的,事实证明我没有你指出的图像。 TY – Bodger 2010-01-25 21:23:58

+6

如果解决了您的问题,请将答案标记为已接受。谢谢。 – 2010-01-25 21:39:55