我正在开发一个连接到Web Service的Android应用程序。如何在重定向到另一个页面时保持页面加载动画?我尝试过以下代码,但每当我按下后退按钮时,加载动画仍然保留在上一页上。有时空白屏幕即将到来。请帮助我改进我的代码并帮助我解决此问题。
public void redirection()
{
ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "","Please wait...", true);
Intent i = new Intent(this, SecondClass.class);
startActivity(i);
}
答案 0 :(得分:0)
关注该链接http://www.androidhive.info/2013/06/android-working-with-xml-animations/
这里定义动画
方法开始
@Override
public void onAnimationStart(Animation animation) {
}
方法结束
@Override
public void onAnimationEnd(Animation animation) {
}
答案 1 :(得分:0)
在此过程中使用asynctask ......
public class asynclass extends AsyncTask<Void, Void, Void>{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "","Please wait...", true);
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
try {
//do your work which u want
}
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
dialog .dismissDialog();
//and here u can pass intent if u want to pass
}
}
答案 2 :(得分:0)
希望您使用AsyncTask来下载数据..
启动进度对话框
Private ProgressDialog pDialog;
尝试将此代码放在onPreExecute()..
上@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pDialog = new ProgressDialog(getParent());
pDialog.setMessage("Please wait ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
完全按照
下载数据后,在PostExcute停止进度对话框中pDialog.dismiss();