How can I add a search text for scrollview

gkumar

Active Member
Licensed User
Longtime User
I have around 500 rows in the scrollview panel. each is having one image as first view, next primary text, secondary text and another 2 images.
So I want to give a search option to the scrollview based on the primary text label. Suppose I have name as "TestPPC" in first label, whenever I type starting from "T", it should point out scrollview with primary text labels starting with "T", If I type "Te" again it should point to rows with primary label text which starts with "Te".

How can I achieve this?
 

mc73

Well-Known Member
Licensed User
Longtime User
I would avoid reconstructing the scrollview, so I would choose to create a new one, clone of the original, placing it upon the old one, and containing the results of our search. Furthemore, there are some very interesting classes and libs for tables in scrollviews, perhaps they've already have such a feature, but I didn't get into trying them yet.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I have around 500 rows in the scrollview panel. each is having one image as first view, next primary text, secondary text and another 2 images.
So I want to give a search option to the scrollview based on the primary text label. Suppose I have name as "TestPPC" in first label, whenever I type starting from "T", it should point out scrollview with primary text labels starting with "T", If I type "Te" again it should point to rows with primary label text which starts with "Te".

How can I achieve this?

You can play with colors, e.g. the matching rows turn to red. Each time you input something, you browse all items in the Scrollview to find the matching rows and you change their color (don't worry, it's blazing fast with 500 items, even on a slow device). Example:
B4X:
Dim pnl as panel, lbl as label
for i = 0 to sv.panel.NumberOfViews -1
pnl = sv.panel.GetView(i)

' to get your label (second position in the item panel):
lbl = pnl.GetView(1)
if lbl.StartsWith(yourtext) then
 pnl.Color = Colors.red
else
 pnl.Color = Colors.Transparent
end if

next
 
Upvote 0
Top