我有一项活动,在服务器响应成功时我想显示几秒/分钟的进度条,几分钟后关闭进度条然后更改活动。我该怎么做。
这是我的代码
public void conditions() throws JSONException {
if (m_oResponseobject.getString("resultdescription").equalsIgnoreCase("Transaction Successful")) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
CProgressBar.getInstance().showProgressBar(getApplicationContext(), "Please wait while rediecting to website");
}
}, 3000);
CProgressBar.getInstance().hideProgressBar();
Intent i = new Intent(CDealAppListingDetails.this, CMainActivity.class);
startActivity(i);
}
}
答案 0 :(得分:1)
int DELAY = 3000;
CProgressBar.getInstance().showProgressBar(getApplicationContext(), "Please wait while rediecting to website");
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
CProgressBar.getInstance().hideProgressBar();
Intent i = new Intent(CDealAppListingDetails.this, CMainActivity.class);
startActivity(i);
}
}, DELAY);
答案 1 :(得分:0)
试试这个:
CProgressBar.getInstance().showProgressBar(getApplicationContext(), "Please wait while rediecting to website");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
CProgressBar.getInstance().hideProgressBar();
Intent i = new Intent(CDealAppListingDetails.this, CMainActivity.class);
startActivity(i);
}
}, 3000);