0

I am currently implementing a map in my project. The map shows certain places around the user with markers.

The markers should provide (among other things) a link to the website of the place, which opens, when clicked, the website.

Apparently, URL formed Strings are not automatically transformed into a link. I tried to solve this by using a custom InfoWindow, but the OnClickListener does not trigger.

Here is the code for the constructor of the InfoWindowAdapter:

MyInfoWindowAdapter(final Context context) {
    this.context = context;

    v = LayoutInflater.from(context).inflate(R.layout.info_window,
            null);
    final TextView tvWebsite = (TextView) v.findViewById(R.id.tvMapWebsite);
    tvWebsite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(tvWebsite.getText().toString()));
            context.startActivity(browserIntent);
            Log.d("MAP CLICK", "Clicked ");
        }
    });
J. Franz
  • 15
  • 5

1 Answers1

0

EDIT: The earlier answer was wrong, the solution to the problem can be found in: Link in marker, as found in the comments

Community
  • 1
  • 1
Julian Kroné
  • 179
  • 1
  • 13
  • First off all, thanks :) I've read through the other question and the solutions. The link appears as link now (blue+underlined) but is not clickable. I am using the full address btw, not a "click here" or something like that. However, it does not react to clicking. Neither `setMovementMethod` nor `android:linksClickable` helped. May it be, that the marker prevents that? – J. Franz Mar 11 '16 at 16:48
  • Hm, okay. Try this solution instead, it seems more related to your issue: [Link in marker](http://stackoverflow.com/a/28298680/4295238) – Julian Kroné Mar 11 '16 at 16:56
  • So, I did it basically like your second solution. However, this causes the whole InfoWindow to fire the event. That would be okay if I would only have the website link in it, but I do have a phone number as well. My OnClick creates a dialog where the user has to choose the action. This may not be the most desirable solution, but it works at least. Thanks again :) – J. Franz Mar 11 '16 at 18:03
  • @JulianKroné Since this answer was accepted based on a comment, and the current content in the answer is wrong, consider editing your answer to contain the correct solution. – Daniel Nugent Mar 11 '16 at 19:03