我知道有成千上万像这样的问题。但我找不到解释。显示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