【发布时间】:2013-04-29 18:56:53
【问题描述】:
当我尝试从线程访问进度条或更新进度时,进度条不会显示。我宁愿只显示一个进度微调器,直到网络活动完成,这个网络活动只是将一些文本数据发布到服务器。这是我到目前为止的代码,感谢任何帮助,
Thread th = new Thread(){
public void run() {
try {
sleep(5000);
while(cnt < 5000){
activty.this.runOnUiThread(new Runnable(){
public void run()
{
ProgressBar pd = (ProgressBar)findViewById(R.id.progressBar1);
pd.setVisibility(0);
pd.setMax(100);
pd.setProgress(cnt);
cnt += 100;
}
});
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
int cnt = 100;
};
th.start();
`
【问题讨论】:
-
你检查了xml吗?可能是其他视图没有为进度条留出足够的空间。
-
这也不错,我可能忽略了这一点。
标签: android