如何在Android中制作真正的启动画面?我不想要定时器或延迟.只是在您的应用程序加载之前显示的启动画面.
目前我正在开发一个android-phonegap项目.
在应用程序加载index.html之前,有一些本机代码正在运行.详细说明是AsyncTask中的SD卡(如果有的话).
我设法在A.Task工作时显示进度条,但此外我想在后台添加一个Splash屏幕.我主要使用Phonegap,只是从本机代码开始.所以我对所有这些布局,主题以及您在.xml文件中定义的其他内容感到困惑.我很确定这对于更大的UI设计也是一个好主意,但对于我现在想要的简单的Splash屏幕,它感觉就像一个完全矫枉过正.
这是来自源代码的片段.直接前进.onCreate()调用AsyncTask做一些工作并在它的PostExecute方法中启动PhoneGap.我希望屏幕出现在onCreate方法或onPreExecute中.作业完成后,屏幕上我将关闭onPostExecute()中的屏幕.我还添加了评论来说明我的想法.
public class myAct extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Show Splash here or in onPreExecute()!
new myAsTa().execute();
}
}
class myAsTa extends AsyncTask<Void, Integer, Boolean> {
ProgressDialog dialog = new ProgressDialog(myAct.this);
@Override
protected void onPreExecute() {
//or show splash here!
dialog.setMessage("Cool Progressbar!");
dialog.show();
super.onPreExecute();
}
protected Boolean doInBackground(Void... values) {
//magician at work!
return true;
}
@Override
protected void onProgressUpdate(Integer... values) {
//insult user here
}
protected void onPostExecute(Boolean result) {
dialog.dismiss(); …Run Code Online (Sandbox Code Playgroud)