简体   繁体   English

从数据库表的URL路径将图像加载到imageView中

[英]load image into imageView from URL path in DB Table

I'm trying to follow this this tutorial to add image into imageView from URL. 我正在尝试按照本教程将图像从URL添加到imageView中。

public class AndroidLoadImageFromURLActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);            

        ImageView image = (ImageView) findViewById(R.id.image);

        String image_url = "http://api.androidhive.info/images/sample.jpg";

        ImageLoader imgLoader = new ImageLoader(getApplicationContext());


        imgLoader.DisplayImage(image_url, image);
    }
}

However, I have the image urls stored in my database table and would like to grab and display dynamically in java. 但是,我将图像URL存储在数据库表中,并希望在Java中动态获取和显示。 please kindly show me how to do this in java? 请向我展示如何在Java中执行此操作? Thank you so much! 非常感谢!

try this link 试试这个链接

here there is a function named showImage() which accepts a url as parameter and returns bitmap which you can use to set to the image view. 这里有一个名为showImage()的函数,该函数接受url作为参数并返回位图,可用于设置图像视图。

and dont forget to give the internet permission when dealing with images to be displayed from a url 并且在处理要从网址显示的图片时,请不要忘记给予互联网许可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM