Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中将数据库中的图像显示到imageview中_Android - Fatal编程技术网

在android中将数据库中的图像显示到imageview中

在android中将数据库中的图像显示到imageview中,android,Android,您好,在我的应用程序中,我有一个基于用户名的登录表单,显示edittext中的所有数据,与数据库中的数据相同,我有图像的所有详细信息。所有数据显示正确,图像未显示,因为我使用了此url http://domainname/xxxxxxx/folder/a.jpg 但上面的图像显示正确,但我想根据用户名显示数据库中的图像,我想显示该图像 有人能帮我吗 String picture1= json.getString("picture"); studentp

您好,在我的应用程序中,我有一个基于用户名的登录表单,显示edittext中的所有数据,与数据库中的数据相同,我有图像的所有详细信息。所有数据显示正确,图像未显示,因为我使用了此url

http://domainname/xxxxxxx/folder/a.jpg
但上面的图像显示正确,但我想根据用户名显示数据库中的图像,我想显示该图像

有人能帮我吗

String picture1= json.getString("picture");
                     studentpic1=(ImageView) findViewById(R.id.imageView1);

                        String image_url = "http://xxxxx/xxx/xxxx/".concat(picture1);
                        ImageLoader imgLoader = new ImageLoader(getApplicationContext());
                        imgLoader.DisplayImage(image_url, 0, studentpic1);

不要直接将图像保存在数据库中。存储其路径,并在检索时通过解析路径显示图像

请获取确切路径并执行类似操作

File imgFile = new  File("/sdcard/Images/test_image.jpg");

if(imgFile.exists()){

    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());

    ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);

    myImage.setImageBitmap(myBitmap);

}

我认为这个例子会对你有所帮助


将所有图像保存在文件夹中,就像我做的一样,但是url如何提及我不知道的一个如果你将路径保存在db中,那么你可以很容易地从pathNot路径获取文件直接将图像保存在数据库a.jpg中像这样的图像我想在android ImageView中显示该图像这就是我说的获取a.jpg的路径并存储它位于数据库中。在imageView中显示图像时,从数据库中获取该路径并对其进行解析,然后在图像视图中显示您是否将用户图像和其他信息存储在同一个表中?同一个表中我使用用户图像保存所有数据通过http post将用户名发送到服务器,在服务器端获取此用户名并选择图像url并将其作为resopnse发送。然后解析响应数据并在图像视图中显示url中的图像!!简单!!:)看到这个了吗
    public void onClick(View arg0) {

    if(btnretrive==arg0)
    {
            String[] col={"image"};
            c=db.query("tableimage", col, null, null, null, null, null);

            if(c!=null){
                c.moveToFirst();
                do{
                    img=c.getBlob(c.getColumnIndex("image"));
                   }while(c.moveToNext());
            }
            Bitmap b1=BitmapFactory.decodeByteArray(img, 0, img.length);

             imageview.setImageBitmap(b1);
             Toast.makeText(this, "Retrive successfully", Toast.LENGTH_SHORT).show();
        }
    }