AnsweredAssumed Answered

Populate AlertDialog from Webservice layer?

Question asked by JFA0427 on Mar 27, 2013
Latest reply on Apr 10, 2013 by JFA0427
I have an actionbar on may mapscreen. (Image 1)

When I select the search icon (or menu item) on my actionbar and alertdialog appears with names that I manually entered into my code (String Array).

How do I populate the alert dialog with location names (names from a layer in the mapservice that has a Names field) from a map service layer? (Image 2)

If you could post some sample code and explain, that would be great.




public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(, menu);  
  return true;
 public boolean onOptionsItemSelected(MenuItem item) {  
  switch (item.getItemId()){ 
   AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                        //This is where I manually entered in my location names.
   final String[] locations = {"Blue Water", "Big Fish ", "Beaverdam", "Wake", "Dock Side", "Oceanview", "Beach 
                        Front", "Lake Side", "Boaters Choice"};
   dialogBuilder.setTitle("Select a Location:");
   dialogBuilder.setItems(locations, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
     //Do something when location is selected within the alertdialog.
   AlertDialog alertDialog = dialogBuilder.create();;