您的位置:首页 > 其它

仿美团(一)之开始界面

2015-07-09 16:22 302 查看
大家都知道现在的APP一点击APP图标后都会出现一张相关的图片在屏幕几秒钟后才会进入登录界面,下面就是美团的开始界面,先上一张图了解了解



java代码如下:

package com.myandroid.meituan;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class MeiTuanStartActivity extends Activity {
private Handler handler=new Handler();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);

handler.postDelayed(new Runnable(){
public void run() {
startActivity(new Intent(MeiTuanStartActivity.this,RegisterActivity.class));
finish();
}

},3000);
}
}

这里用的是Handler消息机制,调用Handler的postDelayed()延时方法;如果不明白或者不了解Handler,我们也可也可以直接用线程:

new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//				startActivity(new Intent(HandlerDemoActivity.this,
//						MyTabActivity.class));

finish();
}

}).start();


布局文件就很简单,布局里面放一张图片就可以:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/bg_logo"
android:scaleType="centerInside"/>
</LinearLayout>


未完待续。。。。。。。本人学android时间不长,代码写法都很简单,便于新手们理解,写不出大神们那样的精髓。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: