android 启动页 实现

本文介绍了一种在Android应用中实现启动页的方法。通过使用Handler和Runnable接口,在显示启动页图片的同时,延迟启动主Activity并关闭启动页。此方法能够平滑过渡到应用程序的主要界面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://www.cnblogs.com/dawei/archive/2010/04/29/1724044.html

 

实现思路,

启动页显示图片,

利用handler将一个线程放入对列中。 线程跳转到另一个activity中去。

 

package com.AlleMedia.zjhf;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.widget.ImageView;

public class StartPage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	
		ImageView iv=new ImageView(this);
		iv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
		iv.setImageResource(R.drawable.startpage);
		setContentView(iv);
		new Handler().postDelayed(new myThread(), 3000);
		
	
}
public class myThread implements Runnable  {
	@Override
	public void run() {
		Intent intent =new Intent(StartPage.this, Main.class);
		StartPage.this.startActivity(intent);
		StartPage.this.finish();
		
	}
}
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值