0
我有一个进度微调的一个问题:进度微调不显示
ProgressBarSpinner spinner = new ProgressBarSpinner();
spinner.execute(Spin);
Login LoginUser = new Login();
if(LoginUser.LoginUser(UserNameValue.getText().toString(), PasswordValue.getText().toString())) {
MessageBox("Login information", "You've been successfully logged in, press OK to continue.");
Document XMLInfo = null;
Passphrase = PasswordValue.getText().toString();
try {
XMLInfo = XMLfromString(LoginUser.ProfileXML);
XML_ProfileParser(XMLInfo);
TickerString = FillProfileSlider(XMLInfo);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Spin.setVisibility(ProgressBar.GONE);
setContentView(R.layout.profile);
TextView ProfileTicker = (TextView)findViewById(R.id.ProfileTicker);
TextView UserInformation = (TextView)findViewById(R.id.NameInfo);
TextView MoneyLabel = (TextView)findViewById(R.id.MoneyInfo);
UserInformation.setText(ProfileInfo.get("FirstName") + " " + ProfileInfo.get("LastName"));
MoneyLabel.setText(ProfileInfo.get("Money") + " Kr");
if(Integer.parseInt(ProfileInfo.get("Messages")) >= 1) {
ImageView MessageImage = (ImageView)findViewById(R.id.MailImage);
MessageImage.setOnClickListener(ImageListener);
MessageImage.setVisibility(ImageView.VISIBLE);
}
ProfileTicker.setText(Html.fromHtml(TickerString));
}
else {
Spin.setVisibility(ProgressBar.GONE);
MessageBox("Login information", "The submitted login information seems to be invalid.");
}
当用户点击登录该被执行。自旋是一个全局的progressbar变量。以下是用于处理微调器的Async类。
private class ProgressBarSpinner extends AsyncTask<ProgressBar, Integer, ProgressBar>
{
protected ProgressBar doInBackground(ProgressBar...Spinner) {
return Spinner[0];
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(ProgressBar Spinner) {
Spinner.setVisibility(ProgressBar.VISIBLE);
Spinner.showContextMenu();
}
}
的问题:如果我尝试登录授权的微调不会被显示在所有后写
Spin.setVisibility(ProgressBar.GONE);
。但是,如果我删除ProgressBar.Gone部分,则将显示微调框。 但是,如果该部分存在,看起来应用程序在它继续(挂起)之前(记录用户或显示错误消息,告诉用户名或密码错误)。
问题是什么?
我知道确保登录没有那么快,以至于在微调设置为GONE之前,微调没有时间显示。
显示所有你的代码。微调不能既是阵列又是微调。 – Snicolas 2012-03-19 19:16:58
我很好奇你为什么使用AsyncTask来管理UI。 – 2012-03-19 19:17:14
我真的不明白这一点,你应该在调用你的AsyncTask并将它隐藏在onPostExecute中之前显示微调器,我不确定你的问题是微调器应该完全从View.GONE中移除 – bbedward 2012-03-19 19:20:45