关闭

Android淡入淡出欢迎界面

标签: 代码
821人阅读 评论(0) 收藏 举报
分类:

直接上代码,比较简单:

package com.example.loadingactivity;

import javax.security.auth.PrivateCredentialPermission;

import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class LoadingActivity extends Activity {

    private ImageView iv;

    @SuppressLint("NewApi") 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.loading);
        iv=(ImageView) findViewById(R.id.iv);
        AlphaAnimation alphaAnimation=new AlphaAnimation(0.0f, 1.0f);
        alphaAnimation.setDuration(8000);
        iv.startAnimation(alphaAnimation);
        alphaAnimation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO Auto-generated method stub
                startActivity(new Intent(LoadingActivity.this, MainActivity.class));
                LoadingActivity.this.finish();
            }
        });

//      Handler handler=new Handler();
//      handler.postDelayed(new Runnable() {
//          
//          @Override
//          public void run() {
//              // TODO Auto-generated method stub
//              //启动mainActivity
//              startActivity(new Intent(LoadingActivity.this, MainActivity.class));
//              LoadingActivity.this.finish();
//          }
//      }, 2000);
    }
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:48347次
    • 积分:1071
    • 等级:
    • 排名:千里之外
    • 原创:58篇
    • 转载:24篇
    • 译文:0篇
    • 评论:9条
    最新评论