2

I am trying to follow a simple splash screen example I found. But I cannot get it to even compile.

First this is the source of the example here.

I am trying to put in into a form that would work for my program.

I created a class in Eclipse for this splash screen

com.ePN.ePNMobileAndroid.ePNSplash

Here is my current main.xml file.

<?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> 

And the class itself

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 error:

no resource found that matches the given name (at src with value '@drawable/com.ePN.ePNMobileAndroid.splash')

I have tried every way I can think to modify the android:src but it will not work.

The class is in error because it cannot resolve r_id.splashscreen in the find by id line.

This is all greek to me, how should this trivial xml and/or java file be modified to make this work?

2
  • Did you try @drawable/com.ePN.ePNMobileAndroid.ePNSplash?
    – Anon.
    Jan 13, 2010 at 20:40
  • Same result, except that it lists "@drawable/com.ePN.ePNMobileAndroid.ePNSplash"
    – Bodger
    Jan 13, 2010 at 20:43

1 Answer 1

8

In android:src="@drawable/com.ePN.ePNMobileAndroid.splash" what are you trying to display in this ImageView? This needs to be a reference to something in your res/drawable directory. So for example if you had a file in res/drawable named my_splash_image.png then the XML attribute would be android:src="@drawable/my_splash_image". Whatever you're trying to do with that package naming inside that attribute isn't going to work.

Looking at the example you are working from, it looks like they had a res/drawable/splash.png file that they were using, that they didn't include in their forum post.

1
  • Yes, it turns out I did not have the image as you have pointed out. TY
    – Bodger
    Jan 25, 2010 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.