不显示Android的日食闪屏图像 [英] android eclipse splash screen image not showing

查看:124
本文介绍了不显示Android的日食闪屏图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个闪屏,但是当我启动我的应用程序的启动屏幕不显示,只黑屏。然而,我的定时器启动画面结束后,我的菜单出现。在我splashscreen.xml,闪屏图像显示的图形布局。但在运行时,它没有。一切正常,除了我的闪屏...

i created a splash screen but when i launch my app the splash screen does not show, just a black screen. however, after my timer for the splash screen ends, my menu comes up. in the graphical layout of my splashscreen.xml, the splash screen image show. but when run, it does not. all is normal except for my splash screen...

code为myMain.java:

code for myMain.java:

package com.immrroj.firstapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class myMain extends Activity
{

@Override
protected void onCreate(Bundle savedInstanceState)
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);
    Thread splashtimer = new Thread()
    {
        @Override
        public void run()
        {
            try
            {
                int timer = 0;
                while (timer < 5000)
                {
                    sleep(100);
                    timer = timer + 100;
                }
                startActivity(new Intent("com.immrroj.firstapp.CLEARSCREEN"));
            } catch (InterruptedException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            finally
            {
                finish();
            }
        }
    };
    splashtimer.run();
}

@Override
protected void onDestroy()
{
    // TODO Auto-generated method stub
    super.onDestroy();
}

@Override
protected void onResume()
{
    // TODO Auto-generated method stub
    super.onResume();
}

@Override
protected void onStart()
{
    // TODO Auto-generated method stub
    super.onStart();
}

@Override
protected void onStop()
{
    // TODO Auto-generated method stub
    super.onStop();
}

}

code为myMenu.java

code for myMenu.java

package com.immrroj.firstapp;

import android.app.Activity;
import android.os.Bundle;

public class myMenu extends Activity
{

@Override
protected void onCreate(Bundle savedInstanceState)
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

}

code为我的main.xml

code for my main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="@drawable/mymenu">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="PRESS ME!!"
    android:textSize="19dp"
    android:textStyle="bold"
    android:width="200dp" android:layout_gravity="right"/>

 <Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="PRESS ME TOO!" 
     android:gravity="center" 
     android:textSize="19dp" 
     android:textStyle="bold" android:width="200dp" android:layout_gravity="right"/>

</LinearLayout>

code我splashscreen.xml ....图像androidsplash没有显示

code for my splashscreen.xml.... the image androidsplash is not showing

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ImageView
    android:src="@drawable/androidsplash"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    />

</LinearLayout>

code为我的Andr​​oid清单:

code for my android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.immrroj.firstapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".myMain" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity
        android:label="@string/app_name"
        android:name=".myMenu" >
        <intent-filter >
            <action android:name="com.immrroj.firstapp.CLEARSCREEN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>

</manifest>

请help..although我可以继续下去,那就真的烦我......

please help..although i can continue, it is really bugging me....

更新:
好吧...我认为它真的很难解决这一问题不会对code具有指针......这样的IM张贴此链接所以任何人都可以看到codeS和鼓捣它...请帮助我...我wnat学习机器人,但即时通讯卡在这里....下载源$ C ​​$ C在这里,它是安全的,我发誓:<一href=\"https://skydrive.live.com/redir.aspx?cid=79ecba5b079a1b4c&resid=79ECBA5B079A1B4C!293&parid=79ECBA5B079A1B4C!113&authkey=!AK8-cta_tThQUms\" rel=\"nofollow\">https://skydrive.live.com/redir.aspx?cid=79ecba5b079a1b4c&resid=79ECBA5B079A1B4C!293&parid=79ECBA5B079A1B4C!113&authkey=!AK8-cta_tThQUms

推荐答案

明白了。

下载您.rar程序,并给它看看。原来有什么不对您的。我不知道到底是什么,但是它是导致不能正确加载布局(可能是因为你让它睡100毫秒,再醒来,检查变量,并一遍又一遍地为100毫秒又睡)。

Downloaded your .rar and gave it a look. Turns out there was something wrong with your Thread. I don't know exactly what, but it was causing the layout not to be properly loaded (probably because you made it sleep for 100 ms, then wake up, check a variable, and sleep again for 100 ms over and over).

我改变你的线程有以下code,现在,它完美的作品我的电话:

I changed your thread with the following code and now it works perfectly on my phone:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splashscreen);

        Thread timer = new Thread() {
            // Thread to show the splash screen, then launch the main screen
            @Override
            public void run() {
                try {
                    sleep(2500); // set this to how long you want to wait before
                                    // showing the main screen
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    Intent mainScreen = new Intent(
                            "com.immrroj.firstapp.CLEARSCREEN");
                    startActivity(mainScreen);
                }
            }
        };
        timer.start();
    }

您可以保留其他在onStart,在onPause等方法了,你不使用那些闪屏呢。

You can leave all the other onStart, onPause etc methods out, you're not using those in a splash screen anyway.

我上传的编辑code在这里:下载

I uploaded the edited code here: Download

祝你的应用程序!

这篇关于不显示Android的日食闪屏图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆