How to place Multiple MapViews v1 inside a ViewFlipper

你说的曾经没有我的故事 提交于 2019-12-07 23:17:09

问题


Objective- I want to show slide shows of different Map Activities which show data according to database, using view flipper(or something similar).

Issues:

  1. View Flipper can't be added to an Activity that is not a MapActivity if flipper contains a mapview.

  2. View Flipper does not allows adding multiple mapviews as one MapActivity can have only one map view.

What I wish to implement

  1. Want to show slide show of multiple MapActivities which show markers,route etc based on database data.
  2. Want to refresh these MapActivities also new data is fetched periodically and database is updated.

I'am unable to find a solution to my problem. I have gone through the following links but they provided no relevant solution:

How can i Implement SlideShow in android?

Can a MapView be placed inside a ViewFlipper somehow?

Please help and suggest what is the best approach for this problem.

Thanks!


回答1:


I did not find standard solution to my problem as view flipper could not be used.I did the following to implement mapview slide show. Its more of a hack than a proper solution but I had no choice.

  1. In a while loop, I kept re-rendering the same map view in the async map task.

2.After 1st map is loaded I called thread.sleep(10000).

3.I cleared the mapview of all routes and markers.

4.I re rendered the 2nd map view.

5.And the steps were repeated continuously.

@Override
    protected Void doInBackground(Void... params) {
        final Drawable marker_inBetween;

        marker_inBetween = getResources().getDrawable(R.drawable.blue_pin);
        marker_inBetween.setBounds(0, 0,
                marker_inBetween.getIntrinsicWidth(),
                marker_inBetween.getIntrinsicHeight());

        helper = new DbHelper(getApplicationContext());
                    // show slide show
            while (true) {
        ArrayList<String> IdList =showAllPeopleOnMap();


                util.haveASleep(slideShowInterval);

                showEachPersonRouteOnMap(IdList);
                resetVariables();//resets lists,routes,removes markers etc
            }
        }
        return null;
    }

Thanks.



来源:https://stackoverflow.com/questions/20093766/how-to-place-multiple-mapviews-v1-inside-a-viewflipper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!