いくつかの要素を検索してGoogleMapに表示するプログラムがあります。マップ上にさまざまなジオポイントを設定するすべての手順が終了する前に、進行状況ダイアログを表示したいと思います。
検索私は、メソッドが終了する前に進行状況ダイアログを表示するこのコードを見つけました。
ProgressDialog dialog;
private class Test extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(Main.this);
dialog.setMessage("Loading....");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.show();
}
@Override
protected Void doInBackground(Void... voids) {
try {
runOnUiThread(new Runnable() {
public void run() {
}
});
//your code
}
@Override
protected void onPostExecute(Void params) {
dialog.dismiss();
//result
}
}
非同期タスクを追加する必要があるクラスは次のようなものです。
public class FindItOnMap extends MapActivity{
static String[] foundResults;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ricerca_condominio);
mapView = (MapView)findViewById(R.id.mapView);
mapController = mapView.getController();
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
mapController.setZoom(12);
myLocationOverlay = new MyLocationOverlay(this, mapView);
List<Overlay> overlays = mapView.getOverlays();
overlays.add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
...........
((ImageButton) findViewById(R.id.btSearch)).setOnClickListener(mSearchListenerListener);
}
OnClickListener mSearchListener = new OnClickListener() {
public void onClick(View v) {
String Location=editorLocation.getText().toString();
String name=editorName.getText().toString();
//static method that updates the lists foundResult
search(name, location);
//static method that use the static array foundResult to update the map
updateMapWithResult();
}
};
ボタンをクリックすると、ソリューションを返すまでに時間がかかるメソッドが呼び出されます
search(name, location);
updateMapWithResult();
問題は、私のクラスがまだMapActivityを拡張していて、多重継承を使用して別のクラスを拡張できないことです。問題を解決するにはどうすればよいですか?