赞
踩
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NUswCSZ7-1689046670792)(//img-blog.csdn.net/20180507212022876?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3RpdGxlNzE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)]
随便新建一个文件,(建议先在桌面建),文件命名为
package com.title71.ywl.demo5; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.widget.TextView; public class Init_Activity extends Activity{ private TextView init_text_number; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.init_activity); init_text_number = (TextView)findViewById(R.id.init_text_number); timer_start(); } private int timer_flag =3; private void timer_start() { final Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { // TODO Auto-generated method stub Message msg =new Message(); msg.what = 1; msg.obj = timer_flag; handler.sendMessage(msg); timer_flag--; if(timer_flag < 0) { timer_flag = 3; timer.cancel(); Intent intent = new Intent(Init_Activity.this,MainActivity.class); startActivity(intent); } } }, 3, 1000); } private Handler handler =new Handler() { public void handleMessage(Message msg) { if(msg.what == 1) { init_text_number.setText(""+msg.obj); } } }; }
<?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" android:background="@drawable/init" > <TextView android:id="@+id/init_text_number" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right" android:text="3" android:textColor="#FFFFFFFF" android:textSize="15sp" /> </LinearLayout>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OHVnQDsF-1689046670793)(//img-blog.csdn.net/20180507213242317?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3RpdGxlNzE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)]
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.title71.ywl.demo5"> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <!--先加载全屏的页面--> <activity android:name=".Init_Activity" android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"><!--先加载全屏的页面--> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!--再加载自己的主页面--><activity android:name=".MainActivity"> </activity><!--再加载自己的主页面--> </application> </manifest>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qYrpnsAO-1689046670793)(//img-blog.csdn.net/20180507214512693?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3RpdGxlNzE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。