Why can't I update TextView and ImageView from OnPostExecute (AsyncTask) - android

I have code in which I want to update the textview and imageview of the InfoWindow. The image and text are retrieved from a sqlite database so I put this in an AsyncTask. When I want to update the textview and imageview of the InfoWindow from OnPostExecute, this doesn't work, the infowindow remains empty.
I found similar questions on StackOverflow but none of the answers solved my problem.
This is my code:
googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
#Override
public boolean onMarkerClick(Marker marker) {
LatLng latLng = marker.getPosition();
// find location id in database
Location location = dbhandler.getLocationByLatLng(latLng);
final int id = location.getId();
addButton.setVisibility(View.VISIBLE);
addButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// open load image fragment
android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
LoadImageFragment fragment = new LoadImageFragment();
// pass id to new fragment
Bundle bundle = new Bundle();
bundle.putInt("id", id);
fragment.setArguments(bundle);
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
});
removeButton.setVisibility(View.VISIBLE);
removeButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// remove markers and images
}
});
new AsyncTask<LatLng, Void, Location>() {
#Override
protected Location doInBackground(LatLng... params) {
LatLng latLng = params[0];
Location location = dbhandler.getLocationByLatLng(latLng);
return location;
}
// find image and text associated with Location
protected void onPostExecute(Location location) {
new AsyncTask<Location, Void, Image>() {
#Override
protected Image doInBackground(Location... params) {
Location location = params[0];
try {
image = dbhandler.getImageByLocationId(location.getId());
}
catch (Exception ex){
Log.d("debug", "failed to fetch image");
image = null;
}
return image;
}
#Override
protected void onPostExecute(Image image) {
// set image and description
if(image != null) {
infoImageView.setImageBitmap(image.getBitmap());
infoTextView.setText(image.getDescription());
updateInfoWindow(image);
}
}
}.execute(location);
}
}.execute(marker.getPosition());
marker.showInfoWindow();
return true;
}
});
// find Location in database
// Setting a custom info window adapter for the google map
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
#Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
#Override
public View getInfoContents(Marker arg0) {
// Getting view from the layout file info_window_layout
View v = getActivity().getLayoutInflater().inflate(R.layout.info_window_layout, null);
// Getting the position from the marker
final LatLng latLng = arg0.getPosition();
infoImageView = (ImageView) v.findViewById(R.id.infoImage);
infoTextView = (TextView) v.findViewById(R.id.infoText);
if(image != null) {
infoImageView.setImageBitmap(image.getBitmap());
infoTextView.setText(image.getDescription());
}
return v;
}
});
}
});

The Info Windows documentation includes this note:
Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
So you have to hold a reference to the Marker whose info you're trying to show, download the image, set the image to your ImageView,and then re-call marker.showInfoWindow() at the end.

please declare your variable Globally
Image image;

Related

How to set info window details in Google Maps Clustering Utility Android?

I am trying to display a list of venues on Google Maps in Android, which can be clustered on zoom out and on zoom in unclustered.
WHEN UNCLUSTERED, an individual item info window can be opened to look at that venue details, and clicked to open a separate activity.
I am using this https://developers.google.com/maps/documentation/android-api/utility/marker-clustering?hl=en
I am doing this :
Getting Map Fragment in onResume()
#Override
public void onResume() {
super.onResume();
// Getting map for the map fragment
mapFragment = new SupportMapFragment();
mapFragment.getMapAsync(new VenuesInLocationOnMapReadyCallback(getContext()));
// Adding map fragment to the view using fragment transaction
FragmentManager fragmentManager = getChildFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.venues_in_location_support_map_fragment_container, mapFragment);
fragmentTransaction.commit();
}
MapReadyCallback :
private class VenuesInLocationOnMapReadyCallback implements OnMapReadyCallback {
private static final float ZOOM_LEVEL = 10;
private final Context context;
public VenuesInLocationOnMapReadyCallback(Context context) {
this.context = context;
}
#Override
public void onMapReady(final GoogleMap map) {
// Setting up marker clusters
setUpClusterManager(getContext(), map);
// Allowing user to select My Location
map.setMyLocationEnabled(true);
// My location button handler to check the location setting enable
map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
#Override
public boolean onMyLocationButtonClick() {
promptForLocationSetting(getContext(), map);
// Returning false ensures camera try to move to user location
return false;
}
});
map.getUiSettings().setMyLocationButtonEnabled(true);
// Disabling map toolbar
map.getUiSettings().setMapToolbarEnabled(false);
}
}
Setting up Cluster Manager
private void setUpClusterManager(final Context context, GoogleMap map) {
// Declare a variable for the cluster manager.
ClusterManager<LocationMarker> mClusterManager;
// Position the map.
LatLng wocLatLng = new LatLng(28.467948, 77.080685);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(wocLatLng, VenuesInLocationOnMapReadyCallback.ZOOM_LEVEL));
// Initialize the manager with the context and the map.
mClusterManager = new ClusterManager<LocationMarker>(context, map);
// Point the map's listeners at the listeners implemented by the cluster
// manager.
map.setOnCameraChangeListener(mClusterManager);
map.setOnMarkerClickListener(mClusterManager);
// Add cluster items (markers) to the cluster manager.
addLocations(mClusterManager);
// Setting custom cluster marker manager for info window adapter
map.setInfoWindowAdapter(mClusterManager.getMarkerManager());
mClusterManager.getMarkerCollection().setOnInfoWindowAdapter(new MyLocationInfoWindowAdapter());
map.setOnInfoWindowClickListener(new MyMarkerInfoWindowClickListener());
}
Adding Cluster items (markers)
private void addLocations(ClusterManager<LocationMarker> mClusterManager) {
for (int i = 0; i < venuesDetailsJsonArray.length(); i++) {
try {
JSONObject thisVenueJson = (JSONObject) venuesDetailsJsonArray.get(i);
JSONObject thisVenueLocationJson = thisVenueJson.getJSONObject("location");
LocationMarker thisVenueMarker = new LocationMarker(thisVenueLocationJson.getDouble("latitude"),
thisVenueLocationJson.getDouble("longitude"), thisVenueJson.getInt("id"));
mClusterManager.addItem(thisVenueMarker);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
MyLocationInfoWIndowAdapter
private class MyLocationInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
#Override
public View getInfoWindow(Marker marker) {
return null;
}
#Override
public View getInfoContents(Marker marker) {
Log.e("getInfoContent", marker.toString());
View venueInfoWindow = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.venues_map_item, null);
return venueInfoWindow;
}
}
MarkerInfoWindowClickListener
private class MyMarkerInfoWindowClickListener implements GoogleMap.OnInfoWindowClickListener {
#Override
public void onInfoWindowClick(Marker marker) {
// TODO: This is the click listener, that means all the info must be added as Tag to Marker
Intent venueDetailsDisplayIntent = new Intent(getActivity(), VenueDetailsDisplayActivity.class);
startActivity(venueDetailsDisplayIntent);
}
}
Location Marker class
public class LocationMarker implements ClusterItem{
private final LatLng mPosition;
private final int id;
public LocationMarker(double lat, double lng, int id) {
mPosition = new LatLng(lat, lng);
this.id = id;
}
#Override
public LatLng getPosition() {
return mPosition;
}
public int getId() {
return this.id;
}
}
The way that I am understanding the flow is this :
onResume --> fragmentTransaction --> VenuesInLocationOnMapReadyCallback --> setUpClusterManager --> addLocations (This adds Custom markers)
Marker Click --> MyLocationInfoWindowAdapter --> getInfoContents(Marker marker)
Marker Info Window click --> MyMarkerInfoWindowClickListener
According to my Understanding of process (I could be wrong):
I am adding an id to my custom LocationMarker when Adding markers in addLocations function.
I need to display different info in infoWindow for different markers.
InfoWindow is displayed using MyLocationInfoWindowAdapter-->getInfoContents(Marker marker)
But here is the rub, I can't find a way to figure out which marker has been clicked upon so that I can set appropriate info in InfoWindow.
On Click on opened InfoWindow I need to open a separate Activity. A/C to me InfoWindow click is handled using MyMarkerInfoWindowClickListener-->onInfoWindowClick(Marker marker) Here too I am having the same problem (I can't figure out which marker's info window has been clicked).

How can I force reload InfoWindow on Android Maps v2 api's Marker?

Hi guys I'm a beginner with Android programming and I'm trying to make custom InfoWindow for my markers on my map application. My InfoWindows have to display a dynamical image (I download and set with Picasso library) different markers ad hoc and some text fields, like the name of the "POI", the address and the distance in minutes, walking and with a car. The problem is that InfoWindowAdapter are images and so I've seen that the only way is to force reload the showing of the marker's infowindow. But if I try (as I seen on some forums and also in others questions here on StackOverflow), my app crash. Below I post my code with comment that can help you and the screen of my app. Really thanks all of you.
Screenshot:
Code:
// ****** Custom InfoWindowAdapter ****** //
map.setInfoWindowAdapter(new InfoWindowAdapter() {
View v = getLayoutInflater().inflate(R.layout.custom_info_window, null);
#Override
public View getInfoWindow(Marker marker) { //As I've seen on the web, if the marker is null and it is showing infowindow, I do a refresh,
if (marker != null && marker.isInfoWindowShown()){ //but with the debug I've seen that it doesn't never enter in this IF statement and nothing happen when the image is loaded.
marker.hideInfoWindow();
marker.showInfoWindow();
}
return null;
}
#Override
public View getInfoContents(final Marker marker) {
BuildInfoMatrix req = new BuildInfoMatrix();
String nome = marker.getTitle();
String currentUrl = "";
int vuoto = -15;
try{
currentUrl=req.findImageUrl(nome); //from another class (BuildInfoMatrix) I retrieve the right image marker URL to display
}catch(Exception e){
currentUrl = "http://upload.wikimedia.org/wikipedia/commons/b/bb/XScreenSaver_simulating_Windows_9x_BSOD.png"; //If the currentURL is null (I haven't set any URL for the marker) it set an error image
}
if (currentUrl == null)
{
currentUrl = "http://upload.wikimedia.org/wikipedia/commons/b/bb/XScreenSaver_simulating_Windows_9x_BSOD.png";
}
ImageView image;
image = (ImageView) v.findViewById(R.id.image_nuvoletta); //image_nuvoletta is where it will be placed on the InfoWindowAdapter
Picasso.with(v.getContext()) //Here with Picasso I download the image and I set into
.load(currentUrl) //R.id.image_nuvoletta
.error(R.drawable.ic_launcher)
.resize(150, 110)
.into(image, new Callback(){
#Override
public void onSuccess(){
//I should reload here (when the image have been downloaded) the infoWindowAdapter but
//if I place here "marker.showInfoWindow()" the app crash; without, nothing happens.
}
#Override
public void onError(){
}
});
/***********************************/
I have the same problem, after going to anywhere and no answer found, i do try my self with new Handler().postDelayed() and it's really work for me.
#Override
public View getInfoWindow(Marker marker) {
// Left it empty
return null;
}
#Override
public View getInfoContents(final Marker marker) {
....
Picasso.with(v.getContext()) //Here with Picasso I download the image and I set into
.load(currentUrl) //R.id.image_nuvoletta
.error(R.drawable.ic_launcher)
.resize(150, 110)
.into(image, new Callback(){
#Override
public void onSuccess(){
new Handler().postDelayed(new Runnable() {
public void run() {
marker.showInfoWindow();
}
}, 500);
}
#Override
public void onError(){
new Handler().postDelayed(new Runnable() {
public void run() {
marker.showInfoWindow();
}
}, 500);
}
});
}
Don't forget to vote if this snippet work for you.

Image Button is not working in InfoWindowAdapter in google map v2

I am trying to add some image button in my marker info.
Though the buttons are added in the view but i cat not click on them.
When I try to click it clicks on the whole view.
My code us given below.
MainActivity.java
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RelativeLayout base;
base = (RelativeLayout) findViewById(R.id.base);
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
try {
initilizeMap(); // Loading map
} catch (Exception e) {
Log.d("asdfadfadf", "asdfasdf");
}
googleMap.setMyLocationEnabled(true);
//googleMap.clear();
IconGenerator i = new IconGenerator(getBaseContext());
i.setStyle(IconGenerator.STYLE_BLUE);
Bitmap tt = i.makeIcon("asdf");
LatLng myLocation = new LatLng(22.899171, 89.500186);
Marker myLocMarker = googleMap.addMarker(new MarkerOptions()
.position(myLocation)
.icon(BitmapDescriptorFactory.fromBitmap(tt))
.title("sssss"));
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
#Override
public View getInfoWindow(Marker mk) {
// TODO Auto-generated method stub
return null;
}
#Override
public View getInfoContents(Marker arg0) {
// TODO Auto-generated method stub
ImageButton set,from,favor;
View view = getLayoutInflater().inflate(R.layout.marker_info,null);
set = (ImageButton) view.findViewById(R.id.imageButtonDestination);
from = (ImageButton) view.findViewById(R.id.imageButtonFrom);
favor = (ImageButton) view.findViewById(R.id.imageButtonFavourite);
set.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("sssssssssssssssss", "sssssssssssssssss");
}
});
return view;
}
});
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap(); // check if map is created successfully or not
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
don't know what to do.
Thanks in advance.
You can't add click listeners to the Marker's InfoWindow as it's not a real view. But a Bitmap that gets rendered from you layout.
From Google Docs: https://developers.google.com/maps/documentation/android/marker#info_windows
Note: The info window that is drawn is not a live view. The view is
rendered as an image (using View.draw(Canvas)) at the time it is
returned. This means that any subsequent changes to the view will not
be reflected by the info window on the map. To update the info window
later (e.g., after an image has loaded), call showInfoWindow().
Furthermore, the info window will not respect any of the interactivity
typical for a normal view such as touch or gesture events. However you
can listen to a generic click event on the whole info window as
described in the section below.
Set GoogleMap.OnInfoWindowClickListener() to your map, implement the interface. You get the marker passed to you, call you action form there:
googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
#Override public void onInfoWindowClick(Marker marker) {
//do your thing here
}
});
I don't understand very well what you require, but according understanding is something of a click on an image to add to the map (a marker). if so may try this:
googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {
#Override
public boolean onMarkerClick(Marker arg0) {
//Your code when you do click
return false;
}
});
I hope help you, and Sorry for my english :(

set InfoWindowAdapter show information only for first marker clicked

So, I have set infowindowadapter for my Google map, but the problem is that when I click on the first marker, it shows the information correctly, but when I hit the second marker it shows information from the first one, so infowindowadapter doesn't refresh.
Can someone tell me why that it and how to fix it?
I was following this post to set infowindowadapter:
custom info window adapter with custom data in map v2
EDIT:
new getMarkers().execute();
mMap.setOnMarkerClickListener(new OnMarkerClickListener() {
#Override
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
return false;
}
});
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
#Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
#Override
public View getInfoContents(Marker marker) {
View view = getLayoutInflater().inflate(R.layout.post_details_on_map,null);
date = (TextView)view.findViewById(R.id.txtMarkerDate);
comment = (TextView)view.findViewById(R.id.txtMarkerComment);
image = (ImageView)view.findViewById(R.id.ivMarkerPicture);
MyMarkerInfo mmi = markerMap.get(marker.getId());
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id",mmi.getId()));
MarkerDetails mDetails = new JSONAdapter().getMarkerDetails(params);
date.setText(mDetails.getDate());
comment.setText(mDetails.getComment());
new getPicture().execute(mDetails.getImageUrl());
return view;
}
});
}
Here is my code for exactly the same operation:
// Setting a custom info window adapter for the google map
map.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
#Override
public View getInfoWindow(Marker args) {
return null;
}
// Defines the contents of the InfoWindow
#Override
public View getInfoContents(Marker args) {
// Getting view from the layout file info_window_layout
View v = getLayoutInflater().inflate(R.layout.info_window_layout, null);
// Getting the position from the marker
clickMarkerLatLng = args.getPosition();
TextView title = (TextView) v.findViewById(R.id.tvTitle);
title.setText(args.getTitle());
map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker)
{
if (SGTasksListAppObj.getInstance().currentUserLocation!=null)
{
if (String.valueOf(SGTasksListAppObj.getInstance().currentUserLocation.getLatitude()).substring(0, 8).contains(String.valueOf(clickMarkerLatLng.latitude).substring(0, 8)) &&
String.valueOf(SGTasksListAppObj.getInstance().currentUserLocation.getLongitude()).substring(0, 8).contains(String.valueOf(clickMarkerLatLng.longitude).substring(0, 8)))
{
Toast.makeText(getApplicationContext(), "This your current location, navigation is not needed.", Toast.LENGTH_SHORT).show();
}
else
{
FlurryAgent.onEvent("Start navigation window was clicked from daily map");
tasksRepository = SGTasksListAppObj.getInstance().tasksRepository.getTasksRepository();
for (Task tmptask : tasksRepository)
{
String tempTaskLat = String.valueOf(tmptask.getLatitude());
String tempTaskLng = String.valueOf(tmptask.getLongtitude());
Log.d(TAG, String.valueOf(tmptask.getLatitude())+","+String.valueOf(clickMarkerLatLng.latitude).substring(0, 8));
if (tempTaskLat.contains(String.valueOf(clickMarkerLatLng.latitude).substring(0, 8)) && tempTaskLng.contains(String.valueOf(clickMarkerLatLng.longitude).substring(0, 8)))
{
task = tmptask;
break;
}
}
/*
findDirections(SGTasksListAppObj.getInstance().currentUserLocation.getLatitude(),
SGTasksListAppObj.getInstance().currentUserLocation.getLongitude(),
clickMarkerLatLng.latitude, clickMarkerLatLng.longitude, GMapV2Direction.MODE_DRIVING );
*/
Intent intent = new Intent(getApplicationContext() ,RoadDirectionsActivity.class);
intent.putExtra(TasksListActivity.KEY_ID, task.getId());
startActivity(intent);
}
}
else
{
Toast.makeText(getApplicationContext(), "Your current location could not be found,\nNavigation is not possible.", Toast.LENGTH_SHORT).show();
}
}
});
// Returning the view containing InfoWindow contents
return v;
}
});
My guess would be that your are getting other markers information the wrong way. try to compare between my method and yours, and try to log the process to see that you are passing the right Id and getting the right info.

Dynamic contents in Maps V2 InfoWindow

I want to show an InfoWindow on markers in a Maps V2 fragment.
Thing is, I want to show BitMaps that are dynamically loaded from the web with Universal Image Downloader.
This is my InfoWindowAdapter:
class MyInfoWindowAdapter implements InfoWindowAdapter {
private final View v;
MyInfoWindowAdapter() {
v = getLayoutInflater().inflate(R.layout.infowindow_map,
null);
}
#Override
public View getInfoContents(Marker marker) {
Item i = items.get(marker.getId());
TextView tv1 = (TextView) v.findViewById(R.id.textView1);
ImageView iv = (ImageView) v.findViewById(R.id.imageView1);
tv1.setText(i.getTitle());
DisplayImageOptions options = new DisplayImageOptions.Builder()
.delayBeforeLoading(5000).build();
imageLoader.getMemoryCache();
imageLoader.displayImage(i.getThumbnailUrl(), iv, options,
new ImageLoadingListener() {
#Override
public void onLoadingStarted(String imageUri, View view) {
// TODO Auto-generated method stub
}
#Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
// TODO Auto-generated method stub
}
#Override
public void onLoadingComplete(String imageUri,
View view, Bitmap loadedImage) {
Log.d("MAP", "Image loaded " + imageUri);
}
#Override
public void onLoadingCancelled(String imageUri,
View view) {
// TODO Auto-generated method stub
}
});
return v;
}
#Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
}
I have 2 problems with this:
As we know the InfoWindow is drawn and later changes to it (in my case the new BitMap on the ImageView) are not shown/ the InfoWindow is not being updated. How can I "notify" the InfoWindow to reload itself when the imageLoader has finished? When I put
marker.showInfoWindow()
into onLoadingComplete it created an infinite loop where the marker will pop up, start loading the image, pop itself up etc.
My second problem is that on a slow network connection (simulated with the 5000ms delay in the code), the ImageView in the InfoWindow will always display the last loaded image, no matter if that image belongs to that ImageWindow/ Marker.
Any suggestions on how to propperly implement this?
You should be doing Marker.showInfoWindow() on marker that is currently showing info window when you receive model update.
So you need to do 3 things:
create model and not put all the downloading into InfoWindowAdapter
save reference to Marker (call it markerShowingInfoWindow)
from getInfoContents(Marker marker)
when model notifies you of download complete call
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isInfoWindowShown()) {
markerShowingInfoWindow.showInfoWindow();
}
I did something similar.
This was still giving me the recession error
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
markerShowingInfoWindow.showInfoWindow();
}
So what i did was simply closes the window and open it again
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
markerShowingInfoWindow.hideInfoWindow();
markerShowingInfoWindow.showInfoWindow();
}
for a better detail version of the same answer here is my original soultion LINK
I was also faced same situation and solved using the following code.
In my adapter I have added public variable
public class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
public String ShopName="";
-------
-------
#Override
public View getInfoWindow(Marker arg0) {
View v;
v = mInflater.inflate(R.layout.info_window, null);
TextView shop= (TextView) v.findViewById(R.id.tv_shop);
shop.setText(ShopName);
}
}
and added MarkerClickListener in my main activity
----
MarkerInfoWindowAdapter mMarkerInfoWindowAdapter;
----
----
#Override
public void onMapReady(GoogleMap googleMap) {
mMarkerInfoWindowAdapter = new MarkerInfoWindowAdapter(getApplicationContext());
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
#Override
public boolean onMarkerClick(final Marker arg0) {
mMarkerInfoWindowAdapter.ShopName= "my dynamic text";
arg0.showInfoWindow();
return true;
}
}
mMap.setInfoWindowAdapter(mMarkerInfoWindowAdapter);
}
I've used the code in this article, and it worked well.
http://androidfreakers.blogspot.de/2013/08/display-custom-info-window-with.html

Categories

Resources