How to display bluetooth data onto listview

Hi, I am currently trying to display Bluetooth data in the Listview component. However, I am lost as to how I should go about with it.

The image below represents the block coding where I receive the Bluetooth data and another coding for saving the data.

The image below represents the block coding whereby I display the saved data onto the listview. However, this is where I have problems as I am unable to display anything as there is always an error message popping up.
image

Do let me know how I can rectify these issues and how I could improve on my block coding

2 Likes

I think the problem is in the one I circled

If you want to return HTML Content you have to set HTMLFormat to true first

and you better provide an aia file and image of all your blocks with this way

get an image of your blocks

get an image of your blocks (→ right mouse click in Blocks area)

Can you upload here a part of your .ino code that sends the data from your BT device?
If you are sending println() then there are better ways of receiving the data.
Look here for answers: FAQ Section: Bluetooth < version 4 (BlueTooth Client) and Arduino
Also, the timer value of your clock may be too long or too short.
Then: GOOD PROGRAMMING PRACTICE:
First, try to display your data in a label or text block, next, if everything is ok, try to find out how ListViews work, then, if you have mastered that, try to combine the two.
If you do not do that, programming will always be like stirring and poking in mud, hoping you will find gold or diamonds. Sometimes you can be lucky.

1 Like

Some more remarks.
You look at the visibility of two labels, which apparently must not both be visible. Can it happen that they are both invisible?
And you do exactly the same, in the then-part for each.
So it would be better to read the data, not depending on the visibility of a label.
Then, you must save the data in the Clock.Timer block, otherwise it will be overwritten the next time the timer goes of and data is recieved.
Now. you will only save data when you press the button. If that is what you want, fine. But save the text, not the html content.
Also be aware, that the way you store it, it will contain only the last value you stored and not a list.
Your display block when pressing the display button, is unfortunately, nonsense.
Do some App Inventor tutorials first!!
As I said above, take things step by step and ask your questions step by step. You will get there!

1 Like

8cf6b4fe8f301e8c795364962e4959e7cc7b0135

Specific nonsense ...

Use only one screen when working with BlueTooth, and do not open Screen1.

Tags are not lists.

How to show last 5 data in a Label:

1 Like

Thank you so much for your kind advice, ill work on it =) And yea I was able to do it with the label component. As per your suggestions I'll look up more into the ListView block

Hi, I have amended my block coding to the best of my abilities. I was able to save the data into a label and then from there call it out to display onto the listview component. Now, I am unsure of how to arrange the data in my Listview component. I would like the data to be arranged either all horizontally; in a single row according to its "Day". Or arranged in a vertical manner. For eg. DayNo. -> PushupNo -> PullupNo.

I have uploaded my whole block coding:

A video of how the application works with the current coding:

Do advise me on how I could go about with this issue. Thank you for your time.

Thank you for your feedback. I kept my coding to 1 screen this time

I suggest looking at bar graphs in

instead of a listview.

Before you make any decisions, try to make some really simple improvements that will make your code much more readable. For example, the cntdownbtn.Click and the cntupdtn.Click contain exactly the same code, except for the first 2 blue blocks. put these green set visible true/false blocks into a procedure, and call this procedure from both .Click blocks. Really simple, but it could save a lot of blocks if you try that for the other buttons too. I would show you, if you upload an .aia of your code.Snap1

1 Like

yeap, i was planning to do the procedures part later on once I have completed the block coding. It's just my personal preference to see the entire code so that I know whats going on. =) However, thanks for your advice, will do the procedure part later on.

Testing.aia (28.2 KB)

I have attached the .aia file as well =). There are 2 other screens namely 'ExerciseData' and 'storagetest' those were just my trial screens, you can ignore it, the main one is in Screen 1.

Just some quick wins:

Instead of all those labels that show "pull up selected" and so on, you could just have one label to which you set the text you need.
Alas, I have no further time today, but maybe you have some ideas now.

And, the question again: what does the Arduino send as data? Does every message end with a println(); ? In that case you can do better with the receiving of the BT data, if not, if you can change the code in the Arduino, you should make it so that every message ends with a println();

1 Like

Thank you very much for your assistance :smiley:

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