<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGISLayerInfo.setVisibility not working as expected - possible bug? in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71220#M520</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having a hard time trying to get layers hiding/unhiding working properly. I just took "HelloWorld" sample code and tweaked it a little just to hide all layers before adding to MapView and... it desn't work! layers is always visible:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
public class HelloWorld extends Activity {
 MapView mMapView = null;
 ArcGISTiledMapServiceLayer tileLayer;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
&amp;nbsp; super.onCreate(savedInstanceState);
&amp;nbsp; setContentView(R.layout.main);

&amp;nbsp; // Retrieve the map and initial extent from XML layout
&amp;nbsp; mMapView = (MapView) findViewById(R.id.map);
&amp;nbsp; /* create a @ArcGISTiledMapServiceLayer */
&amp;nbsp; tileLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");

&amp;nbsp; tileLayer.setOnStatusChangedListener(new OnStatusChangedListener() {
&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;

&amp;nbsp;&amp;nbsp; public void onStatusChanged(Object source, STATUS status) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; debug("LAYER STATUS CHANGE: source=" + source.toString() + " status=" + status);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == STATUS.INITIALIZED) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (ArcGISLayerInfo layer : ((ArcGISTiledMapServiceLayer) source).getLayers()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisible(false);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debug(" Hiding Layer:" + layer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add tiled layer to MapView
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mMapView.addLayer((ArcGISTiledMapServiceLayer) source);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });

&amp;nbsp; mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;

&amp;nbsp;&amp;nbsp; public void onStatusChanged(Object source, STATUS status) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; debug("MAP STATUS CHANGE: source=" + source.toString() + " status=" + status);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == STATUS.LAYER_LOADED &amp;amp;&amp;amp; (source == tileLayer)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (ArcGISLayerInfo layer : ((ArcGISTiledMapServiceLayer) source).getLayers()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debug(" Layer:" + layer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });

 }

 @Override
 protected void onPause() {
&amp;nbsp; super.onPause();
&amp;nbsp; mMapView.pause();
 }

 @Override
 protected void onResume() {
&amp;nbsp; super.onResume();
&amp;nbsp; mMapView.unpause();
 }

 private void debug(String message) {
&amp;nbsp; if (BuildConfig.DEBUG) Log.d("MY_DEBUG", message);
 }

}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here's the output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
MY_DEBUG&amp;nbsp; LAYER STATUS CHANGE: source=com.esri.android.map.ags.ArcGISTiledMapServiceLayer@4129ada0 status=INITIALIZED
MY_DEBUG&amp;nbsp;&amp;nbsp; Hiding Layer:ArcGISLayerInfo [name=World Street Map, id=0, visible=false, minScale=0.0, maxScale=0.0,isShowLegend=true]
MY_DEBUG&amp;nbsp; MAP STATUS CHANGE: source=com.esri.android.map.MapView@4128c698 status=INITIALIZED
MY_DEBUG&amp;nbsp; MAP STATUS CHANGE: source=com.esri.android.map.ags.ArcGISTiledMapServiceLayer@4129ada0 status=LAYER_LOADED
MY_DEBUG&amp;nbsp;&amp;nbsp; Layer:ArcGISLayerInfo [name=World Street Map, id=0, visible=false, minScale=0.0, maxScale=0.0,isShowLegend=true]
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It says that layer has visibility set to false although I can still see it on the screen. I have already tried a much simpler code with only one listener attached to mMapView - same result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or thought would be much appreciated! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Mar 2013 13:52:50 GMT</pubDate>
    <dc:creator>AdrianWieczorek</dc:creator>
    <dc:date>2013-03-27T13:52:50Z</dc:date>
    <item>
      <title>ArcGISLayerInfo.setVisibility not working as expected - possible bug?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71220#M520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having a hard time trying to get layers hiding/unhiding working properly. I just took "HelloWorld" sample code and tweaked it a little just to hide all layers before adding to MapView and... it desn't work! layers is always visible:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
public class HelloWorld extends Activity {
 MapView mMapView = null;
 ArcGISTiledMapServiceLayer tileLayer;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
&amp;nbsp; super.onCreate(savedInstanceState);
&amp;nbsp; setContentView(R.layout.main);

&amp;nbsp; // Retrieve the map and initial extent from XML layout
&amp;nbsp; mMapView = (MapView) findViewById(R.id.map);
&amp;nbsp; /* create a @ArcGISTiledMapServiceLayer */
&amp;nbsp; tileLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");

&amp;nbsp; tileLayer.setOnStatusChangedListener(new OnStatusChangedListener() {
&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;

&amp;nbsp;&amp;nbsp; public void onStatusChanged(Object source, STATUS status) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; debug("LAYER STATUS CHANGE: source=" + source.toString() + " status=" + status);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == STATUS.INITIALIZED) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (ArcGISLayerInfo layer : ((ArcGISTiledMapServiceLayer) source).getLayers()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisible(false);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debug(" Hiding Layer:" + layer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add tiled layer to MapView
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mMapView.addLayer((ArcGISTiledMapServiceLayer) source);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });

&amp;nbsp; mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;

&amp;nbsp;&amp;nbsp; public void onStatusChanged(Object source, STATUS status) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; debug("MAP STATUS CHANGE: source=" + source.toString() + " status=" + status);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == STATUS.LAYER_LOADED &amp;amp;&amp;amp; (source == tileLayer)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (ArcGISLayerInfo layer : ((ArcGISTiledMapServiceLayer) source).getLayers()) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debug(" Layer:" + layer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });

 }

 @Override
 protected void onPause() {
&amp;nbsp; super.onPause();
&amp;nbsp; mMapView.pause();
 }

 @Override
 protected void onResume() {
&amp;nbsp; super.onResume();
&amp;nbsp; mMapView.unpause();
 }

 private void debug(String message) {
&amp;nbsp; if (BuildConfig.DEBUG) Log.d("MY_DEBUG", message);
 }

}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here's the output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
MY_DEBUG&amp;nbsp; LAYER STATUS CHANGE: source=com.esri.android.map.ags.ArcGISTiledMapServiceLayer@4129ada0 status=INITIALIZED
MY_DEBUG&amp;nbsp;&amp;nbsp; Hiding Layer:ArcGISLayerInfo [name=World Street Map, id=0, visible=false, minScale=0.0, maxScale=0.0,isShowLegend=true]
MY_DEBUG&amp;nbsp; MAP STATUS CHANGE: source=com.esri.android.map.MapView@4128c698 status=INITIALIZED
MY_DEBUG&amp;nbsp; MAP STATUS CHANGE: source=com.esri.android.map.ags.ArcGISTiledMapServiceLayer@4129ada0 status=LAYER_LOADED
MY_DEBUG&amp;nbsp;&amp;nbsp; Layer:ArcGISLayerInfo [name=World Street Map, id=0, visible=false, minScale=0.0, maxScale=0.0,isShowLegend=true]
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It says that layer has visibility set to false although I can still see it on the screen. I have already tried a much simpler code with only one listener attached to mMapView - same result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or thought would be much appreciated! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2013 13:52:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71220#M520</guid>
      <dc:creator>AdrianWieczorek</dc:creator>
      <dc:date>2013-03-27T13:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISLayerInfo.setVisibility not working as expected - possible bug?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71221#M521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try putting the visiblity statements&amp;nbsp; on map.setonstatuschangelistener.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;map.setOnStatusChangedListener(new OnStatusChangedListener() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; private static final long serialVersionUID = 1L;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; public void onStatusChanged(Object source, STATUS status) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (source == map &amp;amp;&amp;amp; status == STATUS.INITIALIZED) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISLayerInfo[] basearcGISLayerInfos = poiLayers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .getLayers();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (ArcGISLayerInfo arcGISLayerInfo :basearcGISLayerInfos)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcGISLayerInfo.setVisible(false);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;});&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 04:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71221#M521</guid>
      <dc:creator>ThomasBinu</dc:creator>
      <dc:date>2013-04-12T04:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISLayerInfo.setVisibility not working as expected - possible bug?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71222#M522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, I've tried that already with no result. As others pointed out in different topics here, it looks like there is indeed some bug around layer.setVisibility method. I hope, next release will fix that!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 15:08:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/arcgislayerinfo-setvisibility-not-working-as/m-p/71222#M522</guid>
      <dc:creator>AdrianWieczorek</dc:creator>
      <dc:date>2013-04-12T15:08:40Z</dc:date>
    </item>
  </channel>
</rss>

