如何在这段时间内将Polyline添加到谷歌地图并显示进度对话框?

时间:2015-06-29 21:11:18

标签: android google-maps android-asynctask google-polyline android-runonuithread

我想显示进度条,而折线将在屏幕上绘制。我知道Polyline只在UI线程中绘制。我试过nextcode,但这没有用。没有进度对话框

 final Handler mHandler = new Handler();

                    class shpLoading extends AsyncTask<Void, Void, Void> {
                        ProgressDialog dialog;

                        @Override
                        protected Void doInBackground(Void... params) {
                            mHandler.post(new Runnable() {
                                public void run() {
                                    googleMap.addPolyline(new PolylineOptions()
                                            .addAll(mRoutePoints)
                                            .width(3)
                                            .color(Color.RED));
                                }
                            });
                            return null;
                        }

                        @Override
                        protected void onPreExecute() {
                            Log.d("myLogs", "onPreExecute");
                            dialog = new ProgressDialog(getActivity());
                            dialog.setMessage("Kraunama...");
                            dialog.setIndeterminate(true);
                            dialog.setCancelable(false);
                            dialog.show();
                        }

                        @Override
                        protected void onPostExecute(Void result) {
                            Log.d("myLogs", "onPostExecute");
                            dialog.dismiss();
                        }
                    }

                    shpLoading shpLoading = new shpLoading();
                    shpLoading.execute();

0 个答案:

没有答案