我们知道,当应用程序做一些漫长的过程,比如从互联网上下载一些信息时,它可能会在加载应用程序之前显示启动画面,当应用程序完全加载时,它将显示主页面.在启动画面活动中,我们必须在线程中加载长进程,以避免在加载应用程序之前显示黑屏.我做了所有这些.但在显示应用程序之前还会出现黑屏.这是启动画面活动的onCreate方法:
protected override void OnCreate (Bundle bundle)
{
try {
base.OnCreate (bundle);
//_dt = DateTime.Now.AddSeconds (_splashTime);
SetContentView (Resource.Layout.Splash );
FirstLoadPB= FindViewById <ProgressBar >(Resource .Id.FirstLoadPB );
FirstLoadingInfo= FindViewById <TextView >(Resource .Id.FirstLoadInfo );
LoadApplication ();
} catch (System.Exception ex) {
Common.HandleException (ex);
}
}
Run Code Online (Sandbox Code Playgroud)
这是LoadApplication方法的代码:
public void LoadApplication()
{
new System.Threading.Thread (new ThreadStart (() =>
{
//Some Codes to load applications- Downloading from web and accessing the storage(Because was many codes - about 100 line- i was clear them.
} …Run Code Online (Sandbox Code Playgroud)