Android中较为简单的自动跳转式欢迎界面设计

步骤一: 编辑activity_welecome.xml如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welecome"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".WelecomeActivity" >

<Button
android:id="@+id/btn_close"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="256dp"
android:contentDescription="@string/close_wele"
android:background="@drawable/close_welecome"
/>
</LinearLayout>

界面显示如下:


步骤二修改AndroidManifest.xml文件,将welecomeActivity设为默认Activity

<activity
android:name="com.huawei.moby.WelecomeActivity"
android:label="@string/title_activity_welecome"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />


<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


步骤三: 在welecomeActivity.java中设置计时器,控制Intent跳转到目标Activity即可


package com.huawei.moby;


import java.util.Timer;
import java.util.TimerTask;


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 WelecomeActivity extends Activity {


private Button btn_close;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welecome);

final Intent it = new Intent(this, LoginActivity.class);
Timer timer = new Timer();
btn_close = (Button) findViewById(R.id.btn_close);

// 定时跳转
TimerTask task = new TimerTask() {
@Override
public void run() {
startActivity(it); //执行
}
};
timer.schedule(task, 1000 * 3);

// 直接跳转
btn_close.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {

startActivity(it);
}
});

}

}


是比较简单的一种跳转实现。

更多相关文章

  1. eclipse android 错误列表
  2. Android中AlertDialog用法实例分析
  3. android studio ndk开发遇到的问题
  4. 九宫格的实现及九宫格源码
  5. 使用valgrind检测Android(安卓)native程序的内存
  6. Android(安卓)Telephony —— 手机信号实时变化源码分析过程记录
  7. Android(安卓)SDK 安装过程 与 安装失败的处理方法
  8. android学习——activity的生命周期
  9. android 显示特殊符号

随机推荐

  1. ASP.NET 2.0在SQL Server 2005上自定义分
  2. sql server2008 日志收缩 命令行
  3. PLSQL并非所有变量都已绑定
  4. mysql5.7 启用gtid,导致无法创建和删除表
  5. MySQL This function has none of DETERM
  6. MySql WorkBench“执行查询到文本输出”
  7. mysql报错注入(显错注入)整理
  8. mysql自定义排序规则函数——field()
  9. 学习SQL Server 2005不得不看的一些图书(
  10. 使用PDO创建长插入SQL查询的最佳方法