在android中显示从JSOUP解析的图像?
我一直在尝试开发一个Android应用程序,它可以解析特定的(企业)网站,并在顶部显示该网站的头部图像,在底部显示新闻,并在其下方有按钮,用于打开一个新的活动来显示业务时间表以及有关业务的任何其他信息。我决定使用 JSOUP,我对它很陌生,但我不知道如何显示图像。我尝试了这样的事情,但它不起作用:
ImageView image = (ImageView) findViewById(R.id.headImage);
Document doc = Jsoup.connect("http://www.example.com/").get();
Elements divs = doc.select("img");
for (Element div : divs) {
Log.d("web Stuff",div.text());
text.setText(text.getText() + "\n" + div.text());
Element myImage = div;
String url = myImage.absUrl("src");
image.setImageDrawable(Drawable.createFromPath(url));
}
我应该如何正确地实现这样的事情?
I've been trying to develop an android app that parses through a specific (business's) website, and display the head image of the site on the top, news on the bottom, and have buttons below it that will open a new activity to display the schedule for the business, and any other information about the business. I decided to use JSOUP, which I am very new to, but I can't figure out how it is that I go about displaying images. I tried something like this, but it didn't work:
ImageView image = (ImageView) findViewById(R.id.headImage);
Document doc = Jsoup.connect("http://www.example.com/").get();
Elements divs = doc.select("img");
for (Element div : divs) {
Log.d("web Stuff",div.text());
text.setText(text.getText() + "\n" + div.text());
Element myImage = div;
String url = myImage.absUrl("src");
image.setImageDrawable(Drawable.createFromPath(url));
}
how am I supposed to correctly implement something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想为多个图像执行此操作,我会将图像加载到新线程中。
当线程完成后,您可以设置图像视图的图像。
I would load the image in a new thread if you want to do it for more than one image.
when the Thread is finished you can set the image of the imageview.