Android程序启动画面之Splash总结(2)

package net.hlovey.s;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class WebGameActivity extends Activity {
 
  private WebView webView; 
   
  private Handler mHandler = new Handler();
 
  private static final String TAG = "WebGameActivity";  
  //菜单
  private static final int MENU_RELOAD = Menu.FIRST;
  private static final int MENU_HELP = Menu.FIRST + 1;
  private static final int MENU_ABOUT = Menu.FIRST + 2;
  private static final int MENU_CLOSE = Menu.FIRST + 3;  
  private int staus  = 0; 
  
  private static final int  STOPSPLASH = 0;
  //time in milliseconds
  private static final long SPLASHTIME = 1000;
  
  private LinearLayout splash;
  private TextView tv;
 
  private Animation myAnimation_Alpha;
  private Animation animatinoGone ;
 
  private Handler splashHandler = new Handler() {
    public void handleMessage(Message msg) {
         switch (msg.what) {
         case STOPSPLASH:
              if( staus == 1 ){               
                splash.startAnimation(animatinoGone);
                splash.setVisibility(View.GONE);
                break;
              }
              sendEmptyMessageDelayed(STOPSPLASH, SPLASHTIME);
         }
         super.handleMessage(msg);
    }
};
 
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_PROGRESS); //去标题栏
    setContentView(R.layout.main);   
    animatinoGone = AnimationUtils.loadAnimation(this,R.anim.alpha_gone); //动画效果
    myAnimation_Alpha = AnimationUtils.loadAnimation(this,R.anim.alpha_action); //动画效果
   
    splash = (LinearLayout) findViewById(R.id.splashscreen);
    tv = (TextView) findViewById(R.id.info);
    tv.setText("正在建立数据连接");
    splash.startAnimation(myAnimation_Alpha);
   
    Message msg = new Message();
    msg.what = STOPSPLASH;
    splashHandler.sendMessageDelayed(msg, SPLASHTIME);
 
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwgwsg.html