Entering a number in ListView elements (for a Leaderboard)

Hi there, I've initialized a variable sr_no to 1 and have been trying to assign its value to a ListView element and then increment it everytime the code executes.

But upon execution, it gives an error.

Can anyone help me with this..?

1 Like

Please provide more infos. How do you assign value to a ListView element ? What error do you get ? Post a screenshot of the blocks that you use

1 Like

I get this error

1 Like

Ok and the blocks you use to assign value to a ListView element ?

1 Like

A simple example, with every click numbers are added to listview starting from 1 ...

2 Likes

So actually I'm trying to insert values from TinyDB to a ListView, which is doing fine, but for serial number, I wish to generate values equal to the no. of times the loop runs, so I initialized to 1 and increment it everytime the loop runs.

1 Like

So there's no direct approach to convert a number into a string..?

1 Like

First of all your blocks are wrong. I do not see anywhere tinydb

1 Like

The TinyDB code works fine, fetching data one by one & inserting it to the ListView, but the value which I have been generating locally, giving me a hard time.

I didn't post all blocks of code bcoz it'd be unnecessary I think & not be easily readable.

1 Like

Try Error message of convert string to number

1 Like

Try something like this

2 Likes

Perhaps using a listview is not the best approach:

1 Like

I decided to store the serial no. in the TinyDB itself & fetch it into the ListView, pfa

But if you notice, that I'm trying to build a leaderboard which should be sorted as per the last column (score) in descending order and the entry at the top should be labeled Sr. No. 1.

Is sorting possible with the approach you've suggested..?

1 Like

List Sorting On App Inventor using Blocks explains how a List can be sorted.

Also look at the community discussions with respect to leader board and you might find an alternative to your present leaderboard.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.