編輯:關於Android編程
首先,我們可以先看一下“手相評分”這款軟件的啟動畫面。如下:
其實,做歡迎界面的原理非常簡單,就是在onCreate函數中啟動一個線程,線程體在睡眠幾秒鐘之後,跳轉
到MainActivity即可。具體實現代碼如下:
WelcomeActivity.java
[java]
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;
/*
*@author: ZhengHaibo
*web: http://blog.csdn.net/nuptboyzhb
*mail: [email protected]
*2013-3-25 Nanjing,njupt,China
*/
public class WelcomeActivity extends Activity {
private static final int GOTO_MAIN_ACTIVITY = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 設置無標題
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 設置全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
MyTimer timer = new MyTimer();
timer.start();//啟動線程
}
Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent();
intent.setClass(WelcomeActivity.this, SystemMain.class);
startActivity(intent);
finish();
break;
default:
break;
}
};
};
public class MyTimer extends Thread {
public MyTimer() {
// TODO Auto-generated constructor stub
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(3000);// 線程暫停時間,單位毫秒
mHandler.sendEmptyMessage(GOTO_MAIN_ACTIVITY);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;
/*
*@author: ZhengHaibo
*web: http://blog.csdn.net/nuptboyzhb
*mail: [email protected]
*2013-3-25 Nanjing,njupt,China
*/
public class WelcomeActivity extends Activity {
private static final int GOTO_MAIN_ACTIVITY = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 設置無標題
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 設置全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
MyTimer timer = new MyTimer();
timer.start();//啟動線程
}
Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent();
intent.setClass(WelcomeActivity.this, SystemMain.class);
startActivity(intent);
finish();
break;
default:
break;
}
};
};
public class MyTimer extends Thread {
public MyTimer() {
// TODO Auto-generated constructor stub
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(3000);// 線程暫停時間,單位毫秒
mHandler.sendEmptyMessage(GOTO_MAIN_ACTIVITY);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
布局代碼activity_welcome.xml
[html]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@drawable/welcome"
xmlns:android="http://schemas.android.com/apk/res/android">
</LinearLayout>
在Android中,很多人會用如下的方法判斷當前網絡是否可用:/** * 獲取當前網絡狀態(是否可用) */ public static boolean isNetwor
背景相信大家對Android Studio已經不陌生了,Android Studio是Google於2013 I/O大會針對Android開發推出的新的開發工具,目前很多
本文分享自己在視頻錄制播放過程中遇到的一些問題,主要包括: 視頻錄制流程 視頻預覽及SurfaceHolder 視頻清晰度及文件大小 視頻文件旋轉 一、視頻錄制
本實例實現每隔5秒上傳一次,通過服務器端獲取手機上傳過來的文件信息並做相應處理;采用Android+Struts2技術。一、Android端實現文件上傳1)、新建一個An