Android Question How to Display Image from Local Dir(fileAsset) or RDC/SQlite Database with Custom Listview Library

omo

Active Member
Licensed User
Longtime User
Please, i need urgent assistance. I have been able to use RDC and Sqlite successfully from database including retrieving blob (image data) from database fields and display on imageview control directly on the b4a form, but i want to display image retrived from database or the one from asset folder into custom listview (library). I have followed different similar tutorials and examples on this forum, but none of them talked about getting picture directly from asset folder or RDC/SQlite database into custom listview. The closest i saw on this forum is on how to load image to listview from a website and Download list of images with HttpUtils2 and CustomListView which can not be modified to get image from file asset or RDC/Sqlite Database. Simple example will be appreciated.
 

omo

Active Member
Licensed User
Longtime User
see if this helps.
Thank you very much XbNnX for your quick response. Your message will help me to look toward another direction if i will get plan B to have escape route, but it has not totally solved my problem. The main problem i am trying to solve is from the database using RDC. I can retreive other fields from database and add it to the custom listview in the last line of the code below. I have converted from image to byte array and used other approaches i know without success. Once the image is added, it error message is always: "Object can not be converted to string"


Sub JobDone(Job As HttpJob)
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
'If Job.GetString = "select_inventory1" Then
' ToastMessageShow(txtSearch.Text & " " & "can not be found", True)
'End If
ProgressDialogHide
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(Job)

Select result.Tag

Case "select_skillweb1"

For Each records() As Object In result.Rows
projid = records(result.Columns.Get("projID"))

downloads = records(result.Columns.Get("downloads"))

link = records(result.Columns.Get("link"))
index1 = records(result.Columns.Get("index"))
description = records(result.Columns.Get("description"))

Dim image As byte
image = records(result.Columns.Get("pic")) 'This is where the main problem is, to display the 'pic' field from database to custom listview


clv1.AddTextItem(projid & " " & downloads & CRLF & CRLF & CRLF & image & CRLF & CRLF & description , "a")
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
if i'm not mistaken there's a result.columns.getbitmap <-function


this will always return a string

I am not sure the function is in RDC, below is the capture for both records(result.Columns.Get("pic")) and result.columns

upload_2017-9-24_20-49-40.png
 
Upvote 0

XbNnX_507

Active Member
Licensed User
Longtime User
I am not sure the function is in RDC, below is the capture for both records(result.Columns.Get("pic")) and result.columns

Sorry, haven't used RDC in a while.

B4X:
Dim image() As byte
image = records(result.Columns.Get("pic"))
dim bmp as bitmap
bmp =  reqManager.BytesToImage(image)

clv1.AddTextItem(projid & " " & downloads & CRLF & CRLF & CRLF & bmp& CRLF & CRLF & description , "a")
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
Sorry, haven't used RDC in a while.

B4X:
Dim image() As byte
image = records(result.Columns.Get("pic"))
dim bmp as bitmap
bmp =  reqManager.BytesToImage(image)

clv1.AddTextItem(projid & " " & downloads & CRLF & CRLF & CRLF & bmp& CRLF & CRLF & description , "a")
No problem, i understand. I used this code as well but no success yet. With this code, image can be displayed directly on control like imageview on the form activity, but not with the custom listview library; instead below image is usually displayed. Object can not be converted to string is always reported.
upload_2017-9-25_8-36-13.png

Thank you very much for your time !
 
Upvote 0

XbNnX_507

Active Member
Licensed User
Longtime User
clv1.addTextItem ( text as string , value as object )
it expects a string and a value object

you are trying to pass a string with bitmap =
clv1.AddTextItem(projid & " " & downloads & CRLF & CRLF & CRLF & bmp& CRLF & CRLF & description , "a")

see my first post download the source

you need first to create a panel then load the layout and use
clv1.addPanel(YourPanel as panel , itemHeigth as int , value as object )
 
Upvote 0
Top