ListViewPlus - additional methods for the ListView component

The emulator runs on the same PC as the web browser I'm using to run the App Inventor UI. It appears to connect to aiStarter using localhost. I start it from the Connect menu, choosing Emulator. This starts the emulator, and then the companion App (within the Emulator), and then runs the project. I have aiStarter installed, and running, and all my projects seem to work fine under the Emulator with this setup. When I try to run the TestListViewPlus project, or I include the ListViewPlus extension in a project, I get the messages I reported previously.

I don't unserstand how I'd use USB or Wifi to connect to the emulator that's running on my PC...? Perhaps you're thinking I have the companion app on my phone, and I could understand if this were the case, but it's not. I could try it I guess, but I haven't at this point.

Cheers, Tim.

I don't use an emulator so I don't know about emulator errors. Does your emulator have the latest Companion installed? CreateElement is a block from the built-in ListView component. So either your Companion is not up to date or there is some problem with the ListView. Make a project with just ListView without the ListViewPlus extension and try it out.

You are using an emulator...
In this case try a device and connect via Wifi or test using the apk file

Taifun

Hi Patryk,

I believe it does have the latest companion installed. I just installed the emulator a few days a ago for the first time, so I'd be surprised if it was old. It reports version 2.65u when the emulator starts up.

No, my app that has a ListView in it works fine under the emulator, until I add ListViewPlus extension (that does nothing, just added an instance to screen1.) I've noticed now though, that another extension I tried (Ai2Tools) reports similar errors, so I may be unfairly singling out ListViewPlus, and it could be a general thing for extensions that use reflection to delve in to the internals.

Cheers, Tim.

Hi Taifun,

A built .apk works fine on my phone. I just like using the emulator on the PC as it is so much more convenient for quick testing while developing.

And I'm only pointing out that it doesn't work under the emulator in case it'd be releatively simple to fix at some time in the future. In the mean time I can live with using my phone to test with.

Cheers, Tim.

Thank you for pointing it out
Let's see, if ithis will be fixed in the next release after this patch has been implemented

Taifun

The current companion version is 2.68. Install the latest version of the companion.

Hi Patryk,

Updating the companion App via the Help / Update the Companion menu item unfortunately didn't seem to work for me (messages appeared in App Inventor saying the install was progressing etc., but nothing appeared in the emultor to be accepted, and the version never updated from 2.65u.)

On googling a bit I found this page: https://community.appinventor.mit.edu/t/aistarter-update-mit-ai2-companion2-to-2-58au/7587. The instructions seemed a bit out of date, but I managed to follow them, and successfully updated the companion app in the emulator to version 2.68u.

Old report in aiStarter:
127.0.0.1 - - [03/Oct/2023 13:32:56] "GET /echeck/ HTTP/1.1" 200 39
Found emulator at emulator-5554
Found companion version 13126500

New report in aiStarter:
127.0.0.1 - - [03/Oct/2023 15:06:40] "GET /ping/ HTTP/1.1" 200 88
Found emulator at emulator-5554
Found companion version 13326800

Unfortunately the same errors as I reported previously still occur.

Cheers, Tim.

I like the extension, it works well and is easy to use. I do have one question.. I see a block that sets the color of the background in ListView .. but is there a block to set the background color of the item? In the example pictured above, the ListView background is a pinkish color and each element/item is light blue .. can that blue color be set with a block?

The element takes the color set in the original ListView component's BackgroundColor property.

The scroll animation is a bit jerky, can you get it to smooth scroll?

This block:

image

scrolling one item at a time

Can you give more context? What is the counter variable? Want a slow scrolling effect?

Here is an example aia

autoScrollWithLV.aia (24.3 KB)

and if possible, a when scroll finished event ?

I think you can see the skipping because it's hard to see the animation when scrolling one step, especially since the standard animation time is short. I can attach my own animation to views, so I think I would have to create a custom configurable animation and use it for scrolling. Then you could specify the speed of scrolling from the start to the end position without having to use a counter. I'll try to do it.

I have improved somewhat by adding top and bottom margins with the decoration block.

Animation speed ?

Try this:
autoScrollWithLV (1).aia (26.2 KB)

1 Like

That is very clever :smiley:

I like that you can also physically scroll it back and forth and it handles that interaction

1 Like

So now it's more universal. I need to go through this extension and freshen it up a bit. I've been playing around with the RecyclerView class a bit lately, so I think I can improve this extension now.

And if you don't need to iterate through the position while scrolling, you can simply set the scroll to the final position and set the time to a sufficiently long time.

1 Like

Could you also add the Kodular 'List Image & Text' component to it? I've watched tutorials on Kodular, but I don't know how to use it in MIT App Inventor since the components are different.

I have put work on this extension on hold for now as I work on improving the built-in ListView component. If everything goes well, the ListView component in AppInventor will have the same functionality as the component in Kodular, and even more...