开发者

convertion from string to image [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:开发者_如何学Python

Show Image View from file path in android?

here image path is stored as string i want convert the string to image and need to view the image in emulator how is this possible? please tell me

thanks


Use an ImageView and add your string as an resource.


Bitmap bm = BitmapFactory.decodeFile(mImagePath);
ImageView image = (ImageView) findViewById(R.id.image_view);
image.setImageBitmap(bm);

Assuming mImagePath is a string that contains your path and R.id.image_view is the ID of an ImageView in your layout.

Good luck!


This answer might help. From that answer:

File imgFile = new  File(“/sdcard/Images/test_image.jpg”);
if(imgFile.exists()){
    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile);
    ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
    myImage.setImageBitmap(myBitmap);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜