如何在 textView 中显示来自 URL 的图像
我有一个文本视图。在我的代码中,我在其中添加了一些文本行。我还想在这些行之间显示来自外部 URL(而不是来自我的资源文件夹)的一些图像。每件事都是动态的,即生成的文本和图像 URL 将在流程上生成。所以我必须通过我的代码获取图像并添加它。
想知道是否有办法在文本视图中插入来自外部 URL 的图像?任何更好的方法也总是受欢迎的。
I have a textView. In my code I am adding some lines of text in it. I also want to display some image from an external URL (not from my resource folder) just in between those lines. Every thing is dynamic i.e. the text generated and the image URL will be generated on the flow.So i have to fetch the image through my code and add it.
Wondering if there is a way to insert images from external URL within text view? Also any better approach is always welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将其与 asynctask 一起使用,
在
doInbackground()
中打开连接在
onPostExecute()
中将图像设置为 textview希望有帮助
You will have to use this along with asynctask,
open connection in
doInbackground()
set image to textview in
onPostExecute()
hope it helps
您可能想要使用异步任务来获取图像。这将在您的其他任务的后台运行。您的代码可能如下所示:
You are going to probably want to use an asynctask to grab the image. This will run in the background from your other tasks. Your code may look something like this: