2014-09-06 62 views
1

我已經在使用Android Studio創建的Android應用上實現了初始屏幕,並且我想將微調器添加到初始屏幕。誰能給我一隻手在此:如何將微調器添加到Android中的splashscreen中

這裏是我的splashScreen.java類代碼:

package com.packagename.appname; 

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

/** 
* Created by VAIO1 on 05/09/2014. 
*/ 
public class splashScreen extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.splash); 
     Thread logoTimer = new Thread() { 

      public void run() { 
        try { 
          sleep(3000); 
          Intent splashIntent = new Intent("com.packagename.appname.SPLASH"); 
          startActivity(splashIntent); 
        } catch (InterruptedException e) { 
         e.printStackTrace(); 
        } finally { 
          finish(); 
        } 
       } 

     }; 
     logoTimer.start(); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 
    } 

} 

這裏是我的splash.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:id="@+id/splashId"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="center" 
     android:src="@drawable/screen" 
     android:cropToPadding="false" 
     android:scaleType="fitXY"/> 


</LinearLayout> 

謝謝對於如何實現這一目標的任何反饋。

+0

在splashActivity中使用spinner有什麼用? – 2014-09-06 05:15:53

+0

爲什麼您每次啓動應用程序時都想浪費用戶三秒鐘的時間?這是愚蠢的,不必要的,並會讓你立即卸載。使用啓動屏幕*只有*如果你真的在做某事 - 比如加載數據或準備資產。 – 323go 2014-09-06 05:20:09

+0

這是一個私人應用程序,在我的公司內部使用...所以這不是浪費時間。所以你的評論絕對沒有影響我使用持續2或3秒,期間的飛濺屏幕決定.. – xzibit 2014-09-06 05:28:10

回答

1
use this code :- 


public class splashScreen extends Activity { 

ProgressDialog progressDialog; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.splash); 
     Thread logoTimer = new Thread() { 

      public void run() { 
        try { 
          sleep(3000); 

          progressDialog = new ProgressDialog(Sync_Screen_activity.this); 
          progressDialog.setMessage("Wait.."); 

          progressDialog.setCancelable(false); 
          progressDialog.show(); 

        } catch (InterruptedException e) { 
         e.printStackTrace(); 
        } finally { 
          Intent splashIntent = new Intent("com.packagename.appname.SPLASH"); 
          startActivity(splashIntent); 
          finish(); 
        } 
       } 

     }; 
     logoTimer.start(); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 
    } 

} 
+0

嗨DaxeshKhatri感謝您的回答...我應該把我的SplashScreen活動名稱(Sync_Screen_activity.this)? – xzibit 2014-09-06 05:41:08

+0

我添加了代碼並指定了progressDialog = new ProgressDialog(splashScreen.this);它不顯示微調...我設置導入android.app.ProgressDialog;顯然,當我添加代碼.... – xzibit 2014-09-06 06:00:20

+0

謝謝你的幫助...我做了它的工作,但四行代碼對應progressDialog下setContentView(R.layout.splash); – xzibit 2014-09-06 06:18:01

相關問題