2014-06-09 56 views
-9

我有一個有啓動畫面的應用程序。我的問題是我需要一個啓動屏幕與風車微調(進度條)。我還添加了android java代碼。在Android中的初始屏幕

Java代碼

package com.SSF; 

import android.os.Bundle; 
import android.widget.Toast; 

import com.worklight.androidgap.WLDroidGap; 

public class SSF extends WLDroidGap { 

    @Override 
    public void onCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 

    } 

    /** 
    * onWLInitCompleted is called when the Worklight runtime framework initialization is complete 
    */ 
    @Override 
    public void onWLInitCompleted(Bundle savedInstanceState){ 


     super.loadUrl(getWebMainFilePath()); 

     // Add custom initialization code after this line 
    } 

} 
+0

有很多的教程互聯網上解釋如何做一個閃屏(和在那裏你必須更換一個進度條提出的案文)。從此開始,如果您遇到問題,請稍後再回來。 – grattmandu03

+2

你爲什麼改變整個問題來處理IOS?所有的答案已經爲Android ...你應該創建一個新的問題,而不是。 –

回答

1

有一個閃屏是多餘的,並且應該避免,除非也許它的應用程序第一次運行。用戶喜歡打開應用程序並立即開始使用它。

只有非常重的應用程序(主要是遊戲)需要加載很多東西,但即使在那裏,也有很多優化來縮短它(例如在不久的將來加載它需要的東西)。

不管怎樣,進度條,只需要建立在中間的進度條圖的佈局,用「的setContentView」就可以了,這就是它......

您也可以自己定製的進度條例如使用this post

0

你可以試試這段代碼。請

public class MainActivity extends Activity { 
    private ImageView splashImageView; 
    boolean splashloading = false; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     splashImageView = new ImageView(this); 
     splashImageView.setScaleType(ScaleType.FIT_XY); 
     splashImageView.setImageResource(R.drawable.ic_launcher); 
     setContentView(splashImageView); 
     // interesting music 
     /** 
     * Gets your sound file from res/raw 
     */ 
     splashloading = true; 
     Handler h = new Handler(); 
     h.postDelayed(new Runnable() { 
      public void run() { 
       splashloading = false; 
       setContentView(R.layout.activity_main); 
      } 

     }, 3000); 

    } 

祝你好運!

+0

我要求的進度條在哪裏? –

+0

對不起,我只想如何工作啓動畫面 – kablu

0

試試下面的代碼: -

// METHOD 1  

     /****** Create Thread that will sleep for 5 seconds *************/   
     Thread background = new Thread() { 
      public void run() { 

       try { 
        // Thread will sleep for 5 seconds 
        // show progress bar here 
        sleep(5*1000); 

        // After 5 seconds redirect to another intent 
        Intent i=new Intent(getBaseContext(),FirstScreen.class); 
        startActivity(i); 

        //Remove activity 
        finish(); 
        // hide progress bar here 

       } catch (Exception e) { 

       } 
      } 
     }; 

     // start thread 
     background.start(); 

更多信息請參見下面的鏈接: -

http://androidexample.com/Splash_screen_-_Android_Example/index.php?view=article_discription&aid=113&aaid=135

http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/

+0

我有另一個疑問,有沒有佈局文件夾,當我創建它和XML文件,並在Java代碼試圖調用使用R.layout.name然後它顯示錯誤,我能做些什麼 –

+0

你必須做出自己的佈局,並把閃屏上的進度條 – duggu

+0

我做了那個人,但是當我在.java代碼中使用佈局時,通過使用setContentView(R.layout.activity_main);我在res文件夾中創建了佈局文件夾,裏面有activity_main,它顯示錯誤爲未解決。 –

0

直到工作燈6.2不可能定製飛濺在基於Worklight的Android應用程序中添加屏幕,無論是添加微調器,延長顯示時間還是創建時間完全定製經驗豐富。

啓動Worklight 6.2如果開發人員如此選擇,整個流程都是可定製的。這被記錄在:Managing the splash screen in an Android-based hybrid application,它也提供了各種代碼示例。

順便說一句,你已經問這個... Splash Screen with loading in four environment(android,ios,blackberry and windows) using html coding or common plugin for hybrid apps