我知道有成千上萬像這樣的問題。但我找不到解釋。顯示OnLocationChanged中的進度對話框
我使用onLocationChanged方法來更新用戶在mapView上的位置。一切安好;我在onCreate方法中顯示一個ProgressDialog,並在OnlocationChanged結束時關閉ProgressDialog,它可以工作。
問題是當我在onLocationChanged方法內創建並顯示進度對話框時。不知何故,它不起作用。我認爲這是因爲該方法在不同的線程上運行。
但我的問題是,如果onLocationChanged方法運行在不同的線程上,爲什麼它讓我忽略對話框但不創建一個新的?
這裏是我的類的一部分:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tiendas);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(false);
ProgressDialog dialog = ProgressDialog.show(StoresActivity.this, "",
"Getting your location", true, true);
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
/////if i show or initialize the dialog here, doesn't work!
updateMap(location) // this function calls asynctask
// for an HTTPrequest
dialog.dismiss();
}
}
該代碼工作,正確關閉對話框,但如果我宣佈或顯示onLocationChanged方法中的對話框,它永遠不會顯示。任何人? 它爲什麼忽略它但不能顯示它?
你可以發佈您的代碼 – 2012-07-11 04:33:15
它就在那裏,謝謝! – 2012-07-11 23:06:27