編輯:關於android開發
效果圖:

閃屏頁用到了handler和CountDownTimer類,還需配置一下Activity的主題,這裡是:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 全屏主題的意思。
實現源碼:
package com.example.shanping;
import java.lang.ref.WeakReference;
import com.example.shanping.MyActivity.MyCountDownTimer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
private MyCountDownTimer mc;
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.textView1);
mc = new MyCountDownTimer(3000, 1000);
mc.start();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(MainActivity.this,MyActivity.class);
startActivity(intent);
}
}, 3000);
}
private Handler handler=new Handler();
/**
* 繼承 CountDownTimer 防范
*
* 重寫 父類的方法 onTick() 、 onFinish()
*/
class MyCountDownTimer extends CountDownTimer {
/**
*
* @param millisInFuture
* 表示以毫秒為單位 倒計時的總數
*
* 例如 millisInFuture=1000 表示1秒
*
* @param countDownInterval
* 表示 間隔 多少微秒 調用一次 onTick 方法
*
* 例如: countDownInterval =1000 ; 表示每1000毫秒調用一次onTick()
*
*/
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onFinish() {
tv.setText("正在跳轉");
}
public void onTick(long millisUntilFinished) {
tv.setText("倒計時(" + millisUntilFinished / 1000 + ")");
}
}
}
Drawable資源的初步使用
Drawable資源的初步使用 剛開始接觸到Android的時候,看到類似下面的一個Button: 當時感覺這樣的button有點像Material Design風
創建第一個Android 5.0應用程序,android5.0
創建第一個Android 5.0應用程序,android5.01、新建一個Andriod項目,並配置相關參數 2、接著下一步 3、接著下一步,配置相關參數 &nb
47.Android 自定義PopupWindow技巧
47.Android 自定義PopupWindow技巧 47.Android 自定義PopupWindow技巧 Android 自定義PopupWindow技巧 前言 P
Activity啟動過程源碼分析
Activity啟動過程源碼分析 其實寫分析源碼文章總會顯得很復雜很乏味,但是梳理自己看源碼時的一些總結也是一種提高。這篇博客分析下Activity啟動過程源碼,我會盡量