ListView GetMainText component

I'm using tinyDB to store some photos (as Base64) and an associated caption for each image. I can load ListView with the captions and have used the ListView CreateElement block for that (mainText, detailText, imageName). The list displays okay - so when I click on an element I wish to extract the mainText and detailText parts. But here is the problem - I cannot get the GetMainText listElement to accept the selected element (eg ListView Selection or Listview SelectionIndex
That aside, at the moment I'm populating imageName with the same image filename for all the ListView elements. But, is there any way that this can be done from the Base64 records in the database?
Thanks for any explanations and help

Show us your ListView Layout?

Yes - you can add a delimiter to the B64 string to add a filename or any other data.

Using a bar '|' as the delimiter:

On restore from TinyDb, the string can be split @ '|'


Thanks for your response. I guess you are thinking ListViewLayout specification relates to the available and behaviour of the component blocks. I wondered that too - but as you can see I have the appropriate setup, but still unable to plug anything into the getMain or getDetail blocks. I even tried just a digit thinking it might be happy with that, but no..

Here is another odd thing what is the point / difference between the getDetailText block (purple item) and the ListView1_SelectionDetailText (green item)? What's more I don't see any corresponding ListView1_SelectionMainText. Somewhat lack of symmetry..

And finally, as far as I can recall it used to be that ListView1_SelectionIndex 0 removed the highlight from the selected item in the list - but now it results is a Runtime Error.

Attached are some screen shots to illustrate the above points. Given these multiple issues I'm wondering if someone has been messing with ListView at source or am I just being a bit paranoic..

Try like this:


Thanks Chris. In fact my database record is a three part list: Image Caption, ImageFilename and Base64 so that avoids the suggested B64|Filename splitting task. Currently I'm not using the ImageFilename slot, except for three test images loaded in the assets - so those ListView records display with an image. For the others it is just a default image. You will see that in a screenshot attachement already sent.

My primary objective is to avoid working with image files (due to Googly / Android 10+ read / write issues) so after image selection from Gallery / Drive they go via Base64 into the database. In effect the images are stored, and available for selection in any order etc, but not as image files. However, the ListView1_CreateElement is looking for an image filename, so I was wondering if there is any trick / workaround to get it to accept something reconstituted from Base64??

One thought was a temporary imagefile could be created and that fed into the ListView1_CreateElement call. Thereafter I'm not sure of the inner workings of ListView. If it then holds on to that as a thumbnail internally to ListView - then great. But if ListView needs continued access to that image filepath then it means creating image files for all the Base64 database records - which more or less defeats the whole purpose of storing the images in a database.

Perhaps someone has discovered a sneeky way around this.

Or better still a software revision to make ListView1_CreateElement take in Base64 data directly. Now that would be GOOD...

Thanks again for any suggestions

Great - thank you. I'll modify my code as per your example and I'm sure that will work well.

This has been requested of the MIT development team, but it will be on a long list!

While you could continue to store as base64 in a database, you would need to output each image you wish to view in the listview to a file, use the ASD for file storage, the ASD is available for all android version back to 4.4.2. Grab the file path and name when converting back from base64, and add this to your database in the correct element for use in the listview.

So why did you ask? However, one Split procedure may be more efficient than three data base reads...........

It sounds as though you might be better off using an SQL Lite DB though. It is certainly worth testing - save image as a 'Blob'.

Search this board for Go Scroll Yourself for how to imitate a List View.

If the data is not going to be edited by the App User, then make an HTML table and display in a WebView (no internet required).

Thanks guys for all your suggestions. I could code an imitation ListView which shows the images from tinyDB along with the associated captions. However, this is really only for a setup screen for a photo slide show which runs in the main screen. Optionally the slide show can include background music and will read out the image descriptions

(See screenshot)

The setup screen is for selecting photos from the device Gallery, Photos or Google Drive and then adding captions. It has a ListView showing the associated image captions and that works fine without the image icons - so I'm starting to think the return on effort may not be worth it.

The app itself is actually for an elederly gent in hospital with some cognative issues. However, the photos setup (and also radio station setup) will be undertken by someone else and only occasionally changed - so needs to be functional but not necessarily too fancy.

When complete I may put it up in the MIT Gallery - although I've not done that before. It will be called GateWay

Hi Fossil

You will need to obtain permission from the broadcasters to display/play their broadcast with your App.

If you send me your images and associated captions I can make an HTML List View - I have a desktop program for that.

Hi Chris,
Thanks for the offer to make an HTML list view look-alike. However, I have achieved the objective of having a display list of photos and associated captions.

It turns out that the CanvasBackgroundImageBase64 does what it says on the tin. So, a VerticalArrangement with canvasses (5 fit my screen layout) can take direct writes from TinyDB Base64 records.

Also the ImageBase64 extension by Rush can be used to display a photo in the 'Image1' component. Thus all the necessary functionality - and the code turns out to be fairly simple.

Overall the Photo Setup screen has in effect 13 points of user interaction such as - selecting a photo from Gallery / Photos / Drive, editing captions, deleting photos, scrolling etc - thus quite a bit of code for all those activities.

In terms of the display list part the main challenge is managing the necessary indexing / pointers between what images are displayed and images in the main list. And of course catching all the usual things like trying to populate the display list when there are zero photos, additions, handling deletes etc. etc. I tend to use an AnyComponent and ObjectID lists approach for quite a lot of that stuff, including at initialisation font sizing.

I experimented with display list scrolling using transparent sprites over each canvas and then checking the Yvelocity when 'flung'. I also contemplated sequential canvas touches within a short time frame (milliseconds). But it was too much of a faff with clocks etc - so ended up with simple push down / up arrows.

Re premissions from broadcasters, I trust that as this app is for personal use that will not be necessary so it will not be published to the forum.

Some screen shots are attached. If you would like a personal copy of the code itself I could send that, but not sure how to go about it.


PS: Just noticed some temporary indexing info still on the display :frowning:

Sounds like you have solved the issue with a good, practical solution. I like your layout too.

You can't presume that. Anything you use for your App that was not made by you may require permission or a license, even for personal use. That includes photographs and icons too.

Thanks Chris. The photos are all mine and I design the buttons and associated icons in LibreOffice, so no copyright issues there, but maybe streaming radio stations are different matter. I've emailed all the stations shown on the screenshot with an explanation of what the app is for. Awaiting replies....