Download tagged <a> in webview

Asked

Viewed 67 times

1

Hello!

I have a webview working, I’m trying to create the following html tag:

 for(int i = 0; i < nm.size(); i++) {
     html.append("<a https://example.com.br/ret/AttachedFile.do?command=showFile&generatedId=").append(id.get(i)).append(">").append(nm.get(i)).append("</a><br />");
 }

That would look like this:

<a https://example.com.br/ret/AttachedFile.do?command=showFile&generatedId=64>Download archive</a><br />

However, when I click on the item to download the content, nothing happens... What do I have to do, so that click download the file with the given url? Thank you!

  • 3

    href is missing before the address you want to access html.append("<a href="https://example.com.br/ret/AttachedFile.do?command=showFile&generatedId="). append(id.get(i)). append(">"). append(nm.get(i)). append("</a><br />");

1 answer

0

As commented by Alisson, you need to put the attribute href on the tag:

html.append("<a href=\"https://example.com.br/ret/AttachedFile.do?command=showFile&generatedId=").append(id.get(i)).append("\">").append(nm.get(i)).</a><br />")

Note the backslashes in the places where there are literal quotation marks (\")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.