You can populate the attributes of a graphic after it has been created using the GraphicsLayer.updateGraphic() method. Once a Graphic is added to a GraphicsLayer it is assigned a UID. This is currently by design so you cannot specify a UID on a new Graphic. The overloaded Graphic constructor that takes a UID parameter is an issue we are working on. As you have observed, when you assign a UID with that constructor it will not be honored with a returned Graphic from GraphicsLayer. We are looking to address this issue. If I understand your scenario correctly, you need to update a graphic with attributes based on user clicking on the graphic. You can use the screen coords x, y from the MapView listener to identify which Graphic you want to update. Below is an example:
mMapView.setOnLongPressListener(new OnLongPressListener() {
private static final long serialVersionUID = 1L;
@Override
public void onLongPress(float x, float y) {
int[] guids = gLayer.getGraphicIDs(x, y, 10);
if(guids.length != 0){
Graphic gr = gLayer.getGraphic(guids[0]);
int uid = gr.getUid();
Map<String,Object> attr = gr.getAttributes();
attr.put("name", "Test");
gLayer.updateGraphic(uid, attr);
Log.d("Test", "Graphic attr update name = "+ gr.getAttributeValue("name"));
}
}