【发布时间】:2011-12-11 10:53:01
【问题描述】:
我创建了一个启动画面,但是当我启动我的应用程序时,启动画面没有显示,只是一个黑屏。但是,在我的启动画面计时器结束后,我的菜单出现了。在我的 splashscreen.xml 的图形布局中,显示了启动画面图像。但是在运行时,它不会。一切正常,除了我的启动画面...
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();
}
}
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);
}
}
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>
我的 splashscreen.xml 的代码....图像 androidsplash 没有显示
<?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>
我的 android 清单代码:
<?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>
请帮忙..虽然我可以继续,但它真的让我很烦....
更新: 好的...我认为如果没有代码就很难解决这个问题...所以我发布此链接以便任何人都可以看到代码并对其进行修改...请帮助我...我想学习 android 但是我卡在这里....在这里下载源代码,我发誓它是安全的:https://skydrive.live.com/redir.aspx?cid=79ecba5b079a1b4c&resid=79ECBA5B079A1B4C!293&parid=79ECBA5B079A1B4C!113&authkey=!AK8-cta_tThQUms
【问题讨论】:
-
你能把
TextView和一些文本放到你的splash xml布局中吗?我的猜测是它没有显示您的图像。 -
我首先删除了图像并放置了一个文本视图......但是,在启动画面加载期间文本也没有显示...... T T
标签: android eclipse splash-screen