私はこのような質問が何千もあることを知っています。しかし、私は私の説明を見つけることができません。
onLocationChangedメソッドを使用して、mapView上のユーザーの場所を更新します。すべて順調; onCreateメソッドにProgressDialogを表示し、OnlocationChangedの最後でそれを閉じれば機能します。
問題は、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メソッド内でダイアログを宣言または表示すると、表示されません。誰か?なぜそれを却下するのに見せられないのですか?