Using Handler to set Visibile/Invisibile a maker
I'm working with the google map for a project. I'm using an handler to set the marker visible o invisibile.
If the zoom of the camera is over the a number I have to set the marker invisible or if the zoom is lower than a number I have to set the marker Invisible. I'm using an ArrayList to save all the markers.
I need to create a timer that will continue to work until the application is closed
My problem is that the handler doesn't start.
Below there is my code:
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
handler.postDelayed(run, 1000);
;
add a comment |
I'm working with the google map for a project. I'm using an handler to set the marker visible o invisibile.
If the zoom of the camera is over the a number I have to set the marker invisible or if the zoom is lower than a number I have to set the marker Invisible. I'm using an ArrayList to save all the markers.
I need to create a timer that will continue to work until the application is closed
My problem is that the handler doesn't start.
Below there is my code:
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
handler.postDelayed(run, 1000);
;
add a comment |
I'm working with the google map for a project. I'm using an handler to set the marker visible o invisibile.
If the zoom of the camera is over the a number I have to set the marker invisible or if the zoom is lower than a number I have to set the marker Invisible. I'm using an ArrayList to save all the markers.
I need to create a timer that will continue to work until the application is closed
My problem is that the handler doesn't start.
Below there is my code:
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
handler.postDelayed(run, 1000);
;
I'm working with the google map for a project. I'm using an handler to set the marker visible o invisibile.
If the zoom of the camera is over the a number I have to set the marker invisible or if the zoom is lower than a number I have to set the marker Invisible. I'm using an ArrayList to save all the markers.
I need to create a timer that will continue to work until the application is closed
My problem is that the handler doesn't start.
Below there is my code:
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
handler.postDelayed(run, 1000);
;
edited Nov 15 '18 at 17:35
Gioele.sandrin
asked Nov 15 '18 at 17:30
Gioele.sandrinGioele.sandrin
945
945
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
this handler.postDelayed(run, 1000); needs to be outside of the runnable body
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
;
handler.postDelayed(run, 1000);
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
|
show 6 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324959%2fusing-handler-to-set-visibile-invisibile-a-maker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
this handler.postDelayed(run, 1000); needs to be outside of the runnable body
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
;
handler.postDelayed(run, 1000);
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
|
show 6 more comments
this handler.postDelayed(run, 1000); needs to be outside of the runnable body
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
;
handler.postDelayed(run, 1000);
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
|
show 6 more comments
this handler.postDelayed(run, 1000); needs to be outside of the runnable body
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
;
handler.postDelayed(run, 1000);
this handler.postDelayed(run, 1000); needs to be outside of the runnable body
final Handler handler = new Handler();
Runnable run = new Runnable()
@Override
public void run()
if (mMap.getCameraPosition().zoom > zoomLevel)
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(false);
else
for (int j = 0; j < players.size(); j++)
Marker removeMarker = players.get(j).marker;
removeMarker.setVisible(true);
;
handler.postDelayed(run, 1000);
answered Nov 15 '18 at 17:35
Nikos HidalgoNikos Hidalgo
1,0961317
1,0961317
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
|
show 6 more comments
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
what's the error?
– Nikos Hidalgo
Nov 15 '18 at 17:40
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
Cannot resolve simbol postDelayed.
– Gioele.sandrin
Nov 15 '18 at 17:42
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
try adding the line handler.postDelayed(run, 1000); in the same scope as the one where the handler is defined, but outside of the runnable.
– Nikos Hidalgo
Nov 15 '18 at 17:45
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
the handler it's not in a function, I need to create a timer that start when I open the application and every second do the istructions within it
– Gioele.sandrin
Nov 15 '18 at 17:47
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
that's what postDelayed does.
– Nikos Hidalgo
Nov 15 '18 at 17:52
|
show 6 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324959%2fusing-handler-to-set-visibile-invisibile-a-maker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown