Attempt to get item number 0, of the list. The minimum valid item number is 1

i got this error: Attempt to get item number 0, of the list. The minimum valid item number is 1

here are my blocks



l3
l4

How do i solve this error

Befire selecting an item from a list make sure the index is > 0

Taifun

thanks, like this?

I got this kind of an error: Select list item: Attempt to get item number 5 of a list of length 4

No, not like that; It just pushes the issue to the other end. Without knowing what your intent is, you can use an if block to only do the action if position != 0. And if you do have an issue with the item number being larger than lenght of list, you can add the condition: IF position <= length of All_Items too.

thanks, i’m working on how to add list to favorites

however when i click on any label, the index remain zero

can i have a clock example

no, like this

if index = 0
then display a nice error message
else continue with your logic

Taifun

Still having problems, can i have a block illustration?

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.

A very good way to learn App Inventor or Kodular is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun

Select list item: Attempt to get item number 0, of the list ({"date …

It looks like that error occurs somewhere else, but not at the screenshot you provided…

Taifun

Here are my blocks




i have placed this label3 to see how index changes when i click on each item

thanks in advance

The Index in list block returns 0 in case the item was not found in the list

Taifun

  1. in recycler view the first itm is wont be zero, i think ( list view only will start with zero), so remove get position + 1… (in your screenshot there are four items only visible. get posiotn+1 become 5, so may be it throws such error.
  2. filter items and all items are same ( see in when fb data changed event)
  3. what you want to print in lable3? just use get text of the clicked label using get id method alone is enough… you are using complex block there it seems

I want when i click on list 2 to display 2, and when i click on list3 to dissplay 3, instead of index to remain zero

i have list of 4 items, but all of them display 0 index on click

If possible try to give some sample aia, not the original

i have no way to inbox you

After finishing my work, i will check it. I am away from pc now so staytune

If you have multiple screens, don’t forget to mention the exct screen name

1 Like

index remain zero when i click on favorite button

i expected to see 1, 2, 3 etc instead of zero

i use this block on when any label click

from here

thanks in advance