Help populating a Spinner with datas from a csv file (only first column)

Hello all,

I am very newbie to App Inventor, but I have tried to read a lot of tutorials and helps about my problem, without success.

I want to populate a Spinner wit the datas in a csv file. This file has 2 columns, one for the kinds of materials, and the other is a property related to that material.

What I want is to populate the Spinner ONLY winth the first column of the file (materials), selecting one of them, and getting the other value in 2nd column as data for calculations.

I only get to populate with both datas from column 1 and 2 in the normal way I have seen in tutorials

blocks

I have tried a lot of things by myself without result. Apart, there are a lot of similar controls (ListPicker, ListView, Spiner, etc) and I do nbot know wich is the best for my proposal. This is an option (only one example) of what I have tried:

blocks1

Thanks in advance for your help

See below , my csv has two colums, and in my example elements in spinner are 1,2,3,4

image

1 Like

Once you have loaded the Elements using @dora_paz's code, you would use the lookup in pairs block with the global data and the .Selection value to get your corresponding value for the selected item.

1 Like

I personally prefer to use List Pickers to save screen space and show a summary or Selected in the .Text, or Listviews if I expect only a small Elements list. I avoid Spinners because there is an exception for the first Element, which I find tiresome.

1 Like

I only wanted to show how to do it , I also do not prefer to use spinners :slight_smile:

Thanks to all. It works super fine. I had tried something similar but, obiously without result... Respecto to Spinner, I will try the other controls to see wich is the best.

Thanks again

1 Like

As an alternative the extension by DevYB offers a similar experience:

1 Like

thanks TIMAI2, it has a very nice look. In the other hands I have tried the ListPicker with the solution given. I am debbuging with my phone by USB. It seems to work, but when I press to show the items, The MIT App closes suddenly to my home screen :open_mouth:

Is you csv file in your assets / Media ?
What does your csv data look like, is it formatted correctly?
Your blocks look OK...

Thnks for your reply. I supousse the csv is ok, because the Spinner and ListView work perfectly...

resistencia.csv (215 Bytes)Sin título

Working OK for me, try this aia project

listpickerTest.aia (2.6 KB)

Well, definetively has something to see with my phone (Lenovo A1010a20 - Android 5.1)... Your project does not work either. :frowning_face:

Thanks, I will use the spinner

Thanks, It works perfectly :+1: