Android Question ListView : change selected item background

robotop

Member
Licensed User
Longtime User
Hi all. In this forum there is a huge quantity of threads about ListView and CustomListView. The original simple "ListView" has no methods to change the appearence of the selected item (as while the user touches the screen on it). Just to explain me better, what I want to do is to capture the item_click and item_longclick events and do two different actions, one for each event. While executing such actions, I simply want the touched item of the list to appear with a different background, just to remember to the user what element of the list has been choosen.

In practice, I need for a method like ListView.Select(index, true) and ListView.Select(index, false). The first one must show the item as the user is still touching it, while the second will show the item in its normal state.

Edited: another important request is to have an event raised when the ListView scrolls, for instance: ListView_Scrolled(updown as Int).

What is the simplest way to do this ? For my needs, the best option would be to add such methods to the original ListView class (creating a new class that inherits the events and methods of the original and adds the new ones). I still use the B4A version 3.82 on a winXP machine and loading most recent versions / libraries requires me to switch to newer OS, that I don't like very much.

Any help will be greatly appreciated, thanks.
 
Last edited:

robotop

Member
Licensed User
Longtime User
Thank you, Erel, for the prompt answer.

The problem with CustomListView is that I can't use it on my old B4A version.
Updating to new versions requests me to switch to Win7+ and I'm trying to avoid this.

I can't understand why a "native" class can't be included in a new one that inherits events and methods from the original and adds new ones.

The changing of background for the selected item is present yet ! It acts when the user touches the item.

Why do not add a method to do it programmatically ? The same is for the other requests. All the events are managed yet by the view. Why do not export the scroll event, for example ?

Anyway... is there a chance to have the controls I need on my actual version of B4A / OS ?

I have an old B4A version, installed on an old Win version and I am old too !

Edited: hope not too old for this job !
 
Last edited:
Upvote 0

robotop

Member
Licensed User
Longtime User
Thank you, Erel.
This is exactly what I want. I will try.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…