使activitys之间的过渡 [英] Make a transition between activitys
问题描述
我需要做一个过渡画面,OU只放一个对话框,因为应用程序给黑屏时创建数据库。
我有谷歌,并找到一些这方面的解决方案。其中的话,是只放一个进度对话框创建数据库时。
我的问题,新手的问题是,我在哪里可以把进度对话框。
A - > BlackScreen - > B,其中A是inicial菜单,和B等画面。我试图把对话框上的和/或B和不工作。所以,我在哪里可以把进度对话框的code,所以它显示了BlackScreen?
对于您必须使用异步任务:类DownloadAsyncTask扩展的AsyncTask<字符串,字符串,太虚>
{ ProgressDialog progressDialog;
@覆盖
在preExecute保护无效(){
super.on preExecute();
progressDialog = ProgressDialog.show(Login.this,,请稍候...);
} @覆盖
保护无效doInBackground(字符串...为arg0){ //做你的工作
} @覆盖
保护无效onProgressUpdate(字符串值...){
super.onProgressUpdate(值);
} @覆盖
保护无效onPostExecute(虚空结果){
super.onPostExecute(结果);
progressDialog.dismiss();
} }
//创建对象
DownloadAsyncTask downloadAsyncTask =新DownloadAsyncTask();
downloadAsyncTask.execute();
现在到你的工作的完成它显示进度对话框内doInbackground写你的逻辑和onPostExecute关闭该对话框并调用其他活动的意图。
I need to make a transition screen, ou just put a dialog, because the app give a black screen when is creating the database.
I have google, and find some solutions for this. One of then, is just put a progress dialog when the database is been created.
My problem, and newbie question is, where do i put the progress dialog.
A -> BlackScreen -> B where A is the inicial menu, and B the other screen. I have tried to put the dialog on A and/or in B and dont work. So where can i put the code of the progress dialog, so it shows in the BlackScreen ?
For that You have to use Async task :
class DownloadAsyncTask extends AsyncTask<String, String, Void>
{
ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(Login.this, "", "Please Wait ...");
}
@Override
protected Void doInBackground(String... arg0) {
//Do your Task
}
@Override
protected void onProgressUpdate(String...values){
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Void result){
super.onPostExecute(result);
progressDialog.dismiss();
}
}
//Create the Object
DownloadAsyncTask downloadAsyncTask = new DownloadAsyncTask(); downloadAsyncTask.execute();
now till your work get's completed it shows progress dialog inside the doInbackground write your logic and onPostExecute dismiss the dialog and call Intent of other Activity.
这篇关于使activitys之间的过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!