我试图按照我发现的简单的启动画面示例.但我甚至无法编译.
首先,这是示例的来源:
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>
Run Code Online (Sandbox Code Playgroud)
而班级本身
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);
}
}
Run Code Online (Sandbox Code Playgroud)
XML有一个错误说:
"找不到与给定名称匹配的资源(在src上,值为'@ drawable/com.ePN.ePNMobileAndroid.splash')"
我已经尝试过各种方式来修改android:src,但它无法正常工作.
该类出错,因为它无法解析find by id行中的r_id.splashscreen.
这对我来说都是希腊人,如何修改这个简单的xml和/或java文件以使其工作?
感谢名单
朱利安
在android:src="@drawable/com.ePN.ePNMobileAndroid.splash"什么是你想在这个ImageView的显示?这需要引用res/drawable目录中的某些内容.因此,例如,如果你有一个名为my_splash_image.png的 res/drawable文件,那么XML属性就是android:src="@drawable/my_splash_image".无论你想用什么做什么包,在该属性中命名都不会起作用.
看看你正在使用的例子,看起来他们有一个他们正在使用的res/drawable/splash.png文件,他们没有包含在他们的论坛帖子中.
| 归档时间: |
|
| 查看次数: |
8850 次 |
| 最近记录: |