Android Spinner to determine Marker Colour

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Android Spinner to determine Marker Colour



I have a spinner which I have created for a project in Android studio. The spinner takes the following values from an array in my strings.xml file.


<string-array name="activity_types">

<item>Games</item>
<item>Learn</item>
<item>Fitness</item>
<item>Make</item>
<item>Explore</item>
<item>Find</item>
</string-array>



I would like to create a function which places a marker of a particular colour onto my map in MainActivity i.e. selecting Games, will place an orange marker on the map, when 'Games' is selected and the 'Place' button (below) is pressed. However, I am not sure how to go about this?


place_btn = (Button) findViewById(R.id.place_btn);
place_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

//what would handle the spinner elements here?

//my marker
static final LatLng EXAMPLELOCATION = new LatLng(-37.813, 144.962);
Marker examplelocation = mMap.addMarker(new MarkerOptions()
.position(EXAMPLELOCATION)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));

//go to my main activity, once the marker is placed
openMainActivity();
}
});



I can see that the Google Maps SDK heading under 'Customise the marker colour' provides a function for handling adding a marker, based on colour, so I guess I am just trying to understand how to tie this into a selection from my spinner?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Qvo11eeg,N2jqmVnM2UOq8sWbHhG8 fnbx WeH98DT qIxXQt,e9RO,0na,ty,uKiz43C2 wub,cfphZZSaQXb 29EKJjB4ORtSe
v3VyW5r8U9cDvfRWJDyrw WjzbdxP,aT6ac96gVotY,V sUC89n3D,G,8ABamGTi1x9MPkD fQ

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty