這裏是我的代碼,進度對話框使用與主題
public ProgressDialog loadingdialog;
public void ShowManager() {
//do something
}
public void startScan() {
loadingdialog = ProgressDialog.show(WifiManagementActivity.this,
"","Scanning Please Wait",true);
new Thread() {
public void run() {
try {
sleep(4000);
ShowManager();
} catch(Exception e) {
Log.e("threadmessage",e.getMessage());
}
loadingdialog.dismiss();
}
}.start();
}
startScan();
基本progressdialog播放功能,但其中ShowManager()被調用行,得到錯誤,
01-07 23:11:36.081: ERROR/threadmessage(576): Only the original thread
that created a view hierarchy can touch its views.
編輯:
ShowManager()是一個更改視圖元素的函數。有點像,
public void ShowManager()
{
TextView mainText = (TextView) findViewById(R.id.wifiText);
mainText.setText("editted");
}
progressdialog正在工作,我收到錯誤的行,我打電話給showmanager()。 – ocanal 2012-01-08 00:03:03
所以發佈showmanager的代碼 – nandeesh 2012-01-08 00:05:12
@nandeesh我編輯了它。 – ocanal 2012-01-08 00:13:26