logo头像
Snippet 博客主题

设置打开新Activity的动画效果

本文于2109天之前发表,文中内容可能已经过时。

package com.jay.demo;

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

public class HomeActivity extends Activity {

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout1);
        Button gotoBtn = (Button) findViewById(R.id.gotobtn);
        gotoBtn.setOnClickListener(listener);
    }
    private OnClickListener listener = new OnClickListener() {

                @Override
                public void onClick(View v) {
                        Intent intent = new Intent(HomeActivity.this, SecondActivity.class);
                        startActivityForResult(intent, 0);
//                        HomeActivity.this.finish();
                        int version =  Integer.valueOf(android.os.Build.VERSION.SDK);
                        if(version > 5 ){
                                overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                        }
//                        HomeActivity.this.finish();
                }
        };
}
上一篇