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.Thanks!JohnCode: public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.actionbar_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.SearchTool:
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() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Do something when location is selected within the alertdialog.
}
});
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();