Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
Android
»
jListView with image
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Good opportunity for a fr...
by
MarkMLl
[
Today
at 11:19:02 pm]
Variant Record Behavior
by
simone
[
Today
at 11:15:35 pm]
Debugging problem (Steppi...
by
jamie
[
Today
at 11:14:27 pm]
AI usefulness discussion
by
Joanna from IRC
[
Today
at 11:04:31 pm]
Does a procedure in a pro...
by
Joanna from IRC
[
Today
at 11:00:05 pm]
[SOLVED] Could not load S...
by
donaldklopper
[
Today
at 10:45:12 pm]
[Solved] Sqlite Update on...
by
Wilko500
[
Today
at 10:35:17 pm]
Strange bugs with Advance...
by
Warfley
[
Today
at 10:07:57 pm]
Identifiers character set
by
PascalDragon
[
Today
at 10:07:11 pm]
TOpenDialog
by
jamie
[
Today
at 10:05:46 pm]
Fpcupdeluxe
by
DonAlfredo
[
Today
at 09:19:07 pm]
Contest: fastest IsAnagra...
by
BrunoK
[
Today
at 09:11:50 pm]
LAMW Install not working
by
dseligo
[
Today
at 09:08:29 pm]
Database example without ...
by
Tanto
[
Today
at 08:27:28 pm]
Difference in fpc and laz...
by
HotShoe
[
Today
at 08:20:30 pm]
Defining Table Structures
by
Handoko
[
Today
at 06:35:05 pm]
Give Pascal a Second Look
by
Joanna from IRC
[
Today
at 05:02:39 pm]
A request or maybe its al...
by
LV
[
Today
at 03:37:56 pm]
Errors when building FPC ...
by
Aruna
[
Today
at 02:03:30 pm]
WS2812 LED string demo wi...
by
MarkMLl
[
Today
at 12:51:02 pm]
Lazarus Release Candidate...
by
Martin_fr
[
Today
at 12:51:00 pm]
How to implement a divide...
by
silvercoder70
[
Today
at 12:50:37 pm]
MPlayer Component, suitab...
by
neodarkman
[
Today
at 12:48:36 pm]
A simple question for Mac...
by
carl_caulkett
[
Today
at 12:12:04 pm]
TsWorbookSource
by
straetch
[
Today
at 11:54:47 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: jListView with image (Read 572 times)
xinyiman
Hero Member
Posts: 2256
jListView with image
«
on:
April 06, 2023, 04:05:27 pm »
Someone explain to me how to put in a listview an image (loaded at runtime retrieved from a record in sqlite) aligned left and the text in the center.
I need it to be able to preview a series of products combined with their name. A thousand thanks
Logged
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1
jmpessoa
Hero Member
Posts: 2312
Re: jListView with image
«
Reply #1 on:
April 06, 2023, 04:35:59 pm »
Hi, xinyiman!
If you can retrieve the image from a record in sqlite....
then you can try some code like theses [events]:
Code: Pascal
[Select]
[+]
[-]
procedure
TAndroidModule1
.
ListView1DrawItemBitmap
(
Sender
:
TObject
;
itemIndex
:
integer
;
itemCaption
:
string
;
out bimap
:
JObject
)
;
begin
if
itemIndex
=
1
then
//only item index = 1 has a image ...
begin
bimap
:
=
ImageFileManager1
.
LoadThumbnailFromAssets
(
'lemur_funny.png'
,
72
,
72
)
;
end
;
end
;
or
Code: Pascal
[Select]
[+]
[-]
procedure
TAndroidModule1
.
ListView1DrawItemWidgetBitmap
(
Sender
:
TObject
;
itemIndex
:
integer
;
widgetText
:
string
;
out bimap
:
JObject
)
;
begin
if
itemIndex
=
1
then
//only item index = 1 has a image ...
begin
bimap
:
=
ImageFileManager1
.
LoadThumbnailFromAssets
(
'lemur_funny.png'
,
72
,
72
)
;
end
;
end
;
«
Last Edit: April 06, 2023, 04:37:37 pm by jmpessoa
»
Logged
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard
xinyiman
Hero Member
Posts: 2256
Re: jListView with image
«
Reply #2 on:
April 06, 2023, 04:49:44 pm »
I was thinking of saving images in base64 in text field. How do I then convert them to bitmaps?
Logged
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1
jmpessoa
Hero Member
Posts: 2312
Re: jListView with image
«
Reply #3 on:
April 06, 2023, 05:21:44 pm »
You can try "jBitmap component" methods:
Code: Pascal
[Select]
[+]
[-]
function
GetBase64StringFromImage
(
_bitmap
:
jObject
;
_compressFormat
:
TBitmapCompressFormat
)
:
string
;
function
GetBase64StringFromImageFile
(
_fullPathToImageFile
:
string
)
:
string
;
function
GetImageFromBase64String
(
_imageBase64String
:
string
)
:
jObject
;
// <-- try this!
Logged
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
Android
»
jListView with image
TinyPortal
© 2005-2018