public class Main extends Activity {
private LayoutInflater m_flater = null;
private LinearLayout mFlash;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.flash);
mFlash = (LinearLayout) findViewById(R.id.mFlash);
mFlash.startAnimation(AnimationUtils
.loadAnimation(this, R.anim.fadeout));
m_flater = getLayoutInflater();
LoadMainTask task = new LoadMainTask(this);
task.execute("");
}
public View LoadMainView(LayoutInflater flater) {
View view = flater.inflate(R.layout.main, null);
Button btnOk = (Button) view.findViewById(R.id.BtnOk);
btnOk.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();
}
});
return view;
}
private class LoadMainTask extends AsyncTask<Object, Object, View> {
public LoadMainTask(Context context) {
}
protected View doInBackground(Object... params) {
View view = null;
view = LoadMainView(m_flater);
// 为了测试加了延时,大家可以在这一块加载资源,数据等
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return view;
}
// 执行完毕
protected void onPostExecute(View view) {
setContentView(view);
}
}
}
AsyncTask异步实现(方便自己后续复习)
最新推荐文章于 2019-08-20 00:38:57 发布