android - Dynamic Loadfrom file image is giving Access vailation on Firemonkey Mobile -
android - Dynamic Loadfrom file image is giving Access vailation on Firemonkey Mobile -
i creating demo application having list box , image. when running application on phone giving me (using image1.loadfromfile('path of image')) segmentation 11 exception. not able display image adding @ run time on phone. using below code dynamic loading image.
procedure tform1.button1click(sender: tobject); var item : tlistboxitem; img : timage; begin item := tlistboxitem.create(listbox1); img := timage.create(item); item begin text := 'vikas'; height := 49; selectable := false; stylelookup := 'listboxitemnodetail'; img.align := talignlayout.left; end; img.multiresbitmap.items[0].bitmap.loadfromfile('path image in .png format'); item.addobject(img); listbox1.addobject(item); end;
how load image dynamically?
you need phone call img.multiresbitmap.add()
method before can access img.multiresbitmap.items[0]
:
creates new tcustombitmapitem bitmap item , adds items array.
for example:
img.multiresbitmap.add; // can utilize img.multiresbitmap.items[0] needed...
alternatively:
var bmp: tfixedbitmapitem; begin ... bmp := img.multiresbitmap.add; // utilize bmp needed... ... end;
if not need multi-resolution images, utilize img.bitmap
property instead:
img.bitmap.loadfromfile(...);
android delphi firemonkey delphi-xe6
Comments
Post a Comment