Searching an item from a list into another list


#1

Well, I’m facing the following situation: I get from my database, data like this:

AAAAAAAA, 2, XXXXXXXXXX
BBBBBBBB, 8, ZZZZZZZZZZZ

I have a Spinner where I have to put just one info, like AAAAAAAA.

What I need is, when I choose an item from the spinner, it must store its relative data to variables, I mean:

If I choose BBBBBBBB, all the rest (8 and ZZZZZZZZZZ) must be put into variables. The same thing is when I choose another item from the Spinner.

I already know that I must have 2 lists. But how to retrieve all data from the second list, based on my choose on the first list (Spinner)?

TIA,


#2

Can you show us some blocks of what have you tried???


#3

Yse, sure!

Here I create the two lists:

image

As you can see, the list lista has just one item, but the list lista_veiculos has 3 items.

Here I was trying to catch what was choosen in the spinner:

image

So, my question is: how to catch the item from the second list, based on the item chosen in the spinner?


#4

I think the problem is that the 2nd list only has 1 item, because you are joining everything in one single string.


#5

But that’s the idea. Look: Let me explain better:

List lista: AAAAAAAA
BBBBBBBB (this is going to be shown in the Spinner).

List lista_veiculos: AAAAAAAA, 2, XXXXXXXXXX
BBBBBBBB, 8, ZZZZZZZZZZZ

When I choose BBBBBBBB in the Spinner, I have to get ALL data from the list lista_veiculos, I mean: BBBBBBBB, 8, ZZZZZZZZZZZ.

It’s like a search, when I choose an item from the 1st list, I have to find it on the 2nd list…


#6

Maybe you can append the lists together after selecting an option in the spinner


#7

I believe this would work:


#8

The problem is that the list lista is the basis of the spinner…


#9

hmmm interesting… I’m gonna try right now.


#10

Not yet, @Ken… see below:


#11

You feed both lists the same info here:


#12

Yes, that’s right. And after this I use the list lista to feed the spinner.


#13

Need to get back to work.
I’ll look again later if i get time.


#14

No problem, Ken. Thanks for your time. Meanwhile I’m gonna try to discover a way here.


#15

@Ismael_Hernandez, I was taking a look on the block Spinner1.AfterSelecting and there is a problem: If the item selected is the first item on the list, this block does not work. Only works if I choose another item.


#16

Guys,

Finally I’ve found the solution!!! Here it is:

image

Based on @Ken’s suggestion, I’ve found this and now I have pointed the right item in the second list.

Thanks to all of you and your suggestions!!


#17

Nice adaptation!
Great work!