2014-01-21 80 views
0

Heyy guys ..我正在做一個簡單的應用程序,用閃屏加框架動畫在啓動屏幕上顯示gif ......事情是..應用程序被安裝但沒有顯示在應用程序抽屜 這是清單。 基本上它是我想先運行的Splash活動,然後是主要活動。我的應用程序沒有顯示在應用程序抽屜

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.placebo" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="10" 
     android:targetSdkVersion="14" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.placebo.Main" 
      android:label="@string/app_name" > 

     </activity> 
     <activity 
      android:name=".Splash" 
      android:label="@string/app_name" 
    > 
      <intent-filter> 
       <action android:name="android.intent.action.Splash" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
      </activity> 
     <activity 
      android:name=".WifiState" 
      ></activity> 
     <activity 
      android:name=".ColorPlay" 
      ></activity> 
    </application> 

</manifest> 

繼承人的飛濺

package com.example.placebo; 

import android.app.Activity; 
import android.content.Intent; 
import android.graphics.drawable.AnimationDrawable; 
import android.os.Bundle; 
import android.widget.ImageView; 

public class Splash extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash); 
     ImageView iv = (ImageView) findViewById(R.id.iv1); 
     iv.setBackgroundResource(R.animator.animation); 
     AnimationDrawable anim = (AnimationDrawable) iv.getBackground(); 
     anim.start(); 
     startActivity(new Intent(Splash.this,Main.class)); 
    } 
} 

繼承人的動畫XML

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:drawable="@drawable/frame_000" android:duration="40"/> 
    <item android:drawable="@drawable/frame_001" android:duration="40"/> 
    <item android:drawable="@drawable/frame_002" android:duration="40"/> 
    <item android:drawable="@drawable/frame_003" android:duration="40"/> 
    <item android:drawable="@drawable/frame_004" android:duration="40"/> 
    <item android:drawable="@drawable/frame_005" android:duration="40"/> 
    <item android:drawable="@drawable/frame_006" android:duration="40"/> 
    <item android:drawable="@drawable/frame_007" android:duration="40"/> 
    <item android:drawable="@drawable/frame_008" android:duration="40"/> 
    <item android:drawable="@drawable/frame_009" android:duration="40"/> 
    <item android:drawable="@drawable/frame_010" android:duration="40"/> 
    <item android:drawable="@drawable/frame_011" android:duration="40"/> 
    <item android:drawable="@drawable/frame_012" android:duration="40"/> 
    <item android:drawable="@drawable/frame_013" android:duration="40"/> 
    <item android:drawable="@drawable/frame_014" android:duration="40"/> 
    <item android:drawable="@drawable/frame_015" android:duration="40"/> 
    <item android:drawable="@drawable/frame_016" android:duration="40"/> 
    <item android:drawable="@drawable/frame_017" android:duration="40"/> 
    <item android:drawable="@drawable/frame_018" android:duration="40"/> 
    <item android:drawable="@drawable/frame_019" android:duration="40"/> 

</animation-list> 

和Main.java

package com.example.placebo; 

    import android.os.Bundle; 
    import android.app.Activity; 
    import android.content.Intent; 
    import android.view.Menu; 
    import android.view.View; 
    import android.view.View.OnClickListener; 
    import android.widget.Button; 

    public class Main extends Activity implements OnClickListener { 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 
      Button b1= (Button) findViewById(R.id.button1); 
      b1.setOnClickListener(this); 
      Button b2= (Button) findViewById(R.id.button2); 
      b2.setOnClickListener(this); 

     } 



     @Override 
     public void onClick(View v) { 
      if(v.getId()==R.id.button1) { 
       startActivity(new Intent(Main.this, WifiState.class)); 
      } 
      if(v.getId()==R.id.button2) { 
       startActivity(new Intent(Main.this, ColorPlay.class)); 
      } 

     } 

    } 

回答

0

更改爲:

protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash); 
    ImageView iv = (ImageView) findViewById(R.id.iv1); 
    iv.setBackgroundResource(R.animator.animation); 
    AnimationDrawable anim = (AnimationDrawable) iv.getBackground(); 
    anim.start(); 
      new Handler().postDelayed(new Runnable() { 

     @Override 
     public void run() { 
       startActivity(new Intent(Splash.this,Main.class)); 
     } 
    }, 2000); 

} 
0

試試這個。

private static int SPLASH_TIME_OUT = 3000; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_splash); 

    //To Delay by 3 Seconds 
    new Handler().postDelayed(new Runnable() { 
     @Override 
     public void run() { 
      // This method will be executed once the timer is over 
      // Start your app main activity 
      Intent i = new Intent(Splash.this, MainActivity.class); 
      startActivity(i); 
      // close this activity 
      finish(); 
     } 
    }, SPLASH_TIME_OUT); 

    } 

您可以只保留繪製的圖像作爲背景activity_splash佈局。

相關問題