1

I want to display a progress circle spinning when adding the markers to my map. The problem is that this function needs to be called from the main UI thread:

mMap.addMarker(mo);

So, how can I call a for loop adding markers while displaying a spinning progress bar on the screen? It's the inverse normal problem, because normally you should display the progress on the main UI and load the data on a thread, but in this case must be inversed because the data adding only can be done on the main UI thread.

Can this be achieved?

halfer
  • 19,824
  • 17
  • 99
  • 186
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
  • can you add more code? if you are already doing this on the ui thread why cant you just update a progress bar while you go through the loop? – Tomer Shemesh Mar 02 '18 at 13:14
  • @TomerShemesh if a for loop is blocking the ui thread how can a different thread display a progress bar spinning? – NullPointerException Mar 02 '18 at 15:22
  • Are you talking about a progressdialog? or a progress bar inside the view in your app? – Tomer Shemesh Mar 02 '18 at 15:31
  • is a progressbar view, it's on my activity layour and my intention is to have it visible and spinning when the loop of addMarker is going on – NullPointerException Mar 02 '18 at 15:33
  • Ah ok. there is no way to do what you are asking. the best thing you can do is prepare all the data for the markers in the background ect, set addMarkersDynamically(true) and then add all the markers you need once everything is ready. If there is still a problem of too many markers you are proboly showing too many to the user anyway. see https://stackoverflow.com/questions/25517170/adding-markers-in-background-while-looping-through-arraylist for more info – Tomer Shemesh Mar 02 '18 at 15:38
  • How many markers do you want to add to your map? – Iavor Mar 02 '18 at 17:13
  • more than a thousand – NullPointerException Mar 02 '18 at 18:00

0 Answers0