<?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 Re: Graphic Attribute Methods in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397561#M2691</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can populate the attributes of a graphic after it has been created using the GraphicsLayer.updateGraphic() method.&amp;nbsp; Once a Graphic is added to a GraphicsLayer it is assigned a UID.&amp;nbsp; This is currently by design so you cannot specify a UID on a new Graphic.&amp;nbsp; The overloaded Graphic constructor that takes a UID parameter is an issue we are working on.&amp;nbsp; As you have observed, when you assign a UID with that constructor it will not be honored with a returned Graphic from GraphicsLayer.&amp;nbsp; We are looking to address this issue.&amp;nbsp; If I understand your scenario correctly, you need to update a graphic with attributes based on user clicking on the graphic.&amp;nbsp; You can use the screen coords x, y from the MapView listener to identify which Graphic you want to update.&amp;nbsp; Below is an example:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mMapView.setOnLongPressListener(new OnLongPressListener() {

 private static final long serialVersionUID = 1L;

 @Override
 public void onLongPress(float x, float y) {
&amp;nbsp; int[] guids = gLayer.getGraphicIDs(x, y, 10);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if(guids.length != 0){
&amp;nbsp;&amp;nbsp; Graphic gr = gLayer.getGraphic(guids[0]);
&amp;nbsp;&amp;nbsp; int uid = gr.getUid();
&amp;nbsp;&amp;nbsp; Map&amp;lt;String,Object&amp;gt; attr = gr.getAttributes();
&amp;nbsp;&amp;nbsp; attr.put("name", "Test");
&amp;nbsp;&amp;nbsp; gLayer.updateGraphic(uid, attr);
&amp;nbsp;&amp;nbsp; Log.d("Test", "Graphic attr update name = "+ gr.getAttributeValue("name"));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:10:35 GMT</pubDate>
    <dc:creator>DanO_Neill</dc:creator>
    <dc:date>2021-12-11T18:10:35Z</dc:date>
    <item>
      <title>Graphic Attribute Methods</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397559#M2689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What happened to the setAttributeValue and removeAttribute methods on the Class Graphic?&amp;nbsp; The only way I see to set attributes is to include them when instantiating the graphic.&amp;nbsp; In my app, I draw a polygon in a graphics layer and then have a popup dialog box asking the user to enter info which will populate the attributes.&amp;nbsp;&amp;nbsp; So my graphic exist before having attributes.&amp;nbsp; How do I populate the attributes after I already instantiated the graphic? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried updateGraphic.&amp;nbsp;&amp;nbsp; I used the constructor that allow you to assign an ID.&amp;nbsp; I then created another graphic with attributes and used the updateGraphic method, but itdid not work.&amp;nbsp; I found that my first graphic did did not contain the graphic ID I assigned, but some random one.&amp;nbsp; How else can I do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why was setAttributeValue and removeAttribute methods removed?&amp;nbsp; Seems to make sense to be able to have such methods.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 15:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397559#M2689</guid>
      <dc:creator>LukeCatania</dc:creator>
      <dc:date>2012-05-07T15:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic Attribute Methods</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397560#M2690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What happened to the setAttributeValue and removeAttribute methods on the Class Graphic?&amp;nbsp; The only way I see to set attributes is to include them when instantiating the graphic.&amp;nbsp; In my app, I draw a polygon in a graphics layer and then have a popup dialog box asking the user to enter info which will populate the attributes.&amp;nbsp;&amp;nbsp; So my graphic exist before having attributes.&amp;nbsp; How do I populate the attributes after I already instantiated the graphic? &lt;BR /&gt;&lt;BR /&gt;I tried updateGraphic.&amp;nbsp;&amp;nbsp; I used the constructor that allow you to assign an ID.&amp;nbsp; I then created another graphic with attributes and used the updateGraphic method, but itdid not work.&amp;nbsp; I found that my first graphic did did not contain the graphic ID I assigned, but some random one.&amp;nbsp; How else can I do this?&lt;BR /&gt;&lt;BR /&gt;Why was setAttributeValue and removeAttribute methods removed?&amp;nbsp; Seems to make sense to be able to have such methods.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually the graphic ID is being assigned.&amp;nbsp; The issue is when I query the graphics layer and use getGraphicIDs to get the ID of the queried graphic, that ID is not the one I assigned.&amp;nbsp; I only have one graphic drawn and only one is returned from the query.&amp;nbsp; Why is the number assigned not returned?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 15:42:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397560#M2690</guid>
      <dc:creator>LukeCatania</dc:creator>
      <dc:date>2012-05-07T15:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic Attribute Methods</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397561#M2691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can populate the attributes of a graphic after it has been created using the GraphicsLayer.updateGraphic() method.&amp;nbsp; Once a Graphic is added to a GraphicsLayer it is assigned a UID.&amp;nbsp; This is currently by design so you cannot specify a UID on a new Graphic.&amp;nbsp; The overloaded Graphic constructor that takes a UID parameter is an issue we are working on.&amp;nbsp; As you have observed, when you assign a UID with that constructor it will not be honored with a returned Graphic from GraphicsLayer.&amp;nbsp; We are looking to address this issue.&amp;nbsp; If I understand your scenario correctly, you need to update a graphic with attributes based on user clicking on the graphic.&amp;nbsp; You can use the screen coords x, y from the MapView listener to identify which Graphic you want to update.&amp;nbsp; Below is an example:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mMapView.setOnLongPressListener(new OnLongPressListener() {

 private static final long serialVersionUID = 1L;

 @Override
 public void onLongPress(float x, float y) {
&amp;nbsp; int[] guids = gLayer.getGraphicIDs(x, y, 10);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if(guids.length != 0){
&amp;nbsp;&amp;nbsp; Graphic gr = gLayer.getGraphic(guids[0]);
&amp;nbsp;&amp;nbsp; int uid = gr.getUid();
&amp;nbsp;&amp;nbsp; Map&amp;lt;String,Object&amp;gt; attr = gr.getAttributes();
&amp;nbsp;&amp;nbsp; attr.put("name", "Test");
&amp;nbsp;&amp;nbsp; gLayer.updateGraphic(uid, attr);
&amp;nbsp;&amp;nbsp; Log.d("Test", "Graphic attr update name = "+ gr.getAttributeValue("name"));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/graphic-attribute-methods/m-p/397561#M2691</guid>
      <dc:creator>DanO_Neill</dc:creator>
      <dc:date>2021-12-11T18:10:35Z</dc:date>
    </item>
  </channel>
</rss>

