Skip to first unread message

FlightPlan

unread,
Jan 22, 2016, 7:14:27 AM1/22/16
to mitappinv...@googlegroups.com
I have created a app which allows me to calculate Air and Flight times to confirm my calculations when filling in a log book using App Inventor 2. It then places these times in a list for consecutive legs flown and calculates the total. It is now fully functional in that I can then see a list of flights and delete a specific leg if I enter this by mistake.

Now that the ability to delete is in place I would like to, when I select a certain line to delete, have the text in that line change to red to highlight which line is to be deleted. I then have a choice of confirming the deletion or cancelling the deletion.I was hoping to accomplish this using the 'replace item at index' block to change the text color, but have had no luck thus far. To this point I can change the actual text on the line selected to be deleted without issue, so I am hoping someone has an idea as to how I can change just the color of text in a list at a specific index.

I will attach an image of the block I have created for you to have a look at. In order to copy the image without copying the whole block I used backpack to copy the images, so it appears that there are no links. Please ignore that, the blocks are fully functional.

Thank you,
Bill
Deletelegsblocks.png

Scott Ferguson

unread,
Jan 24, 2016, 6:06:58 PM1/24/16
to MIT App Inventor Forum
Hi Bill-
Could you do a screen capture of the device screen?
It looks like you may be using labels to display your data and if so, you can change the TextColor and BackgroundColor.
This may require using the advanced 'Any' blocks for the Label component if you intend to display a list of flight legs in a set of stacked Labels on the screen.
In that way you can specify an index to a particular label to insert text, or change the TextColor for.
You can also control if a Label is visible or not so you can display only the number of labels needed at any given time.
---
sf

FlightPlan

unread,
Jan 25, 2016, 9:17:16 AM1/25/16
to MIT App Inventor Forum
Hi Scott,

I'll attach a screenshot of the list as with a few legs entered as an example. Basically the list consists of data from 6 labels: OUT OFF ON IN AIR and FLIGHT. Once I input the times for the current leg in the current leg screen and save the leg it adds it to the list on the current logpage screen. I hadn't thought of the 'any block' mode, so I am going to have a look and see if I can figure that out. In the meantime, if you see a method that would work, let me know. Also, let me know if there is anything else you need to see to help make sense of what I am trying to accomplish.
Thanks very much for the reply.

Bill

Screenshot_2016-01-25-09-59-07.png

Scott Ferguson

unread,
Jan 25, 2016, 10:13:48 AM1/25/16
to MIT App Inventor Forum
I have attached a suggested method to highlight the row to be deleted.
It is simpler than having to change the text color for each number in the row, but that is still an option if you prefer.
Each row of labels is contained within an HorizontalArrangement.
The HorizontalArrangement containing the leg to be deleted has it's BackgroundColor changed to indicate the pending deletion.
---
sf
MarkFlightLeg.aia
Capture.PNG
Screenshot_2016-01-25-09-05-11.png

FlightPlan

unread,
Jan 25, 2016, 7:47:08 PM1/25/16
to mitappinv...@googlegroups.com
Thank you so much for the suggestion. The result is exactly what I am looking for. I will try to incorporate this into my app over the next few days, and I'll let you know how I make out with it.

One question I have is why this does not work with text color. I had set up a similar block as you had using text color instead of background color and I got an error stating: 'property setting was expecting a Label component but got a string instead'. Is there a reason for this?

Bill
Componentblocks.png

Scott Ferguson

unread,
Jan 25, 2016, 9:13:29 PM1/25/16
to mitappinv...@googlegroups.com
Each label has a component block that is always the last block in the list of the label's blocks and contains only the name of the label.
That is the block that was expected when the error message displayed.
So you must use the advanced 'Any' Label blocks with the component block to set a label's TextColor or do as I did for the component blocks for the three HorizontalArrangements and put those component blocks in a list.
They can be used with an advanced block later and a select list item block with the index to the label for setting the TextColor for any label based on the index in the list.
My explanation sounds confusing but it is not that complicated to do.
---
sf

FlightPlan

unread,
Jan 27, 2016, 10:53:52 PM1/27/16
to mitappinv...@googlegroups.com
So I have tried to incorporate your suggestion into my app and am hitting a bit of a wall. Currently the OUT, OFF, ON , IN, AIR and FLT lists are organized in a vertical arrangement. I have a foreach block to parse the data and to display the lists properly in that vertical column, and the a block called 'showlist' that retrieves the list when called for in other blocks. I have been able to successfully display my data in a horizontal arrangement, but from what I understand from your suggestion I would have to create a horizontal arrangements for each leg, so that I can then highlight the leg to be deleted using background color.
If I am interpreting the proper use of the advanced 'any label' block, I should be able to change the background or text color of the desired leg using my existing vertical arrangement lists. I am attaching a copy of the blocks used to create and display the lists as well as the blocks which successfully identify and add the text ' Del. Leg?' to the leg to be deleted using the list replace block. What I am wondering is, with the block that I am using to parse and display the list (ie display outlist), am I inadvertently creating a 'string' at the end of the label that causes the error when using the any label block, or am I completely misunderstanding its proper usage.

The image I have attached is specific to the OUT list, but all of the other lists display in the same manner. The ' Save Leg' Long click is where I save each leg from the 'input' screen to the 'current leg' screen you are already familiar with.

Thanks,

Bill
OUTListBlock.png

Abraham Getzler

unread,
Jan 28, 2016, 10:37:06 AM1/28/16
to MIT App Inventor Forum
Last time I saw so many red flags, it was a case of measles.

Why do you have so many TinyDB synonyms?
You know that there's only one TinyDB per app, right?

ABG

Scott Ferguson

unread,
Jan 28, 2016, 2:05:05 PM1/28/16
to MIT App Inventor Forum
I will assume that you have three labels in your OUT vertical arrangment for this explanation.
If you want to set the BackgroundColor of the second label's text in that arrangement you would use the advanced any label block to set the BackGroundColor.
Since you must provide a label component block for the advanced BackgroundColor block you must have all three OUT label component blocks in a list.
Then you would use a select list item (<name of OUT label components list>, 2) to access the component block for setting the second label's BackgroundColor.
---
sf

FlightPlan

unread,
Jan 29, 2016, 1:31:54 PM1/29/16
to MIT App Inventor Forum
Okay, thanks for the clarification Scott. At present I only have one OUT label and list the various legs OUT values within that one label via a list, so that must be where the problem lie. I have been working a lot and have not had any time to try re-arranging the labels, but I will as soon as I can.

Bill

FlightPlan

unread,
Jan 29, 2016, 1:38:47 PM1/29/16
to MIT App Inventor Forum
In a sense I am trying to give my app a mild dose of the measles in appearance, but as you can see, I am not having huge success at the moment!

I was using so many synonyms because I was having trouble with TinyDB recalling some values, and to give me some better oversight. It also will allow me to selectively clear some of the tinyDB llists if I need to, without affecting the others down the road if I need that functionality. That was the idea anyway, but I am still learning!

Scott Ferguson

unread,
Jan 29, 2016, 7:04:09 PM1/29/16
to MIT App Inventor Forum
What you are attempting to do is pretty advanced for the majority of our users.
I am confident that you will be able to get it to work, however.
---
Happy Inventing!
sf
Reply all
Reply to author
Forward
0 new messages