Search code examples
androidsearchapp-inventor

Search box needs to be able to search individual words from search box


I am using MIT App Inventor 2 and I am trying to make my search box more useful.

Right now a have a bunch of lists and it only works if the words in the "search" textbox match the word in the list exactly. I want it to be more dynamic. For example If someone puts oj container in the search box I want it to search the lists for oj container and if that does not come up with anything then search the lists for both oj and container separately. And if it finds one of these words in the list to follow on to the next action, which is to open up the appropriate page.

So far my code looks like this:

enter image description here

Tell me if this code make sense. Thanks.

Here are some more code screenshots


Solution

  • No, it does not make sense. The split at spaces block returns a list and using the is in list? block you can't search for a list of things, only for a "thing" (a single word in your case). Therefore you will have to search for each single word in your list using a for each item in list loop.

    Also there is some redundancy in your blocks. If searching for oj container is successful, the search for oj also is successful, which means, you can remove the blocks to search for the complete sentence...

    See my solution for the first part of your screenshot.

    enter image description here