I'm trying to populate a label with text but am getting this error msg:
Property setter was expecting a com.google.appinventor.components.runtime.Label component but got a File instead.
I've been successfully using this structure in other non-file components so I'm puzzled as to why this is generating an error?
That green block needs to be switched from generic to non generic.
Which Label gets the text?
Like so ?
Which Label gets the text?
I have 8 labels named:
lblAudioFile1
...
lblAudioFile8
If I use lblAudioFile1 the file data displays in the first lblAudioFile1 field.
I'm trying to loop 8 times and populate the fields with saved text (without having to have 8 specific lbl statements thus I am using the any component method).
So I see the loop working but all the saved data is populating at the top label (lblAudioFile1) each time instead of populating down the 8 fields.
From what you say do you have 8 file components and 8 labels ? If so you will need two lists, one for the file components and one for the labels. Then in your anyFileGotText event get the index of the file component used from its list and select the corresponding label from the label list using the index.
You need to put the labels and the filecomps into a 2 list. And in the loop you can call them one by one with their ID that represent their place in the list.
Is it 8 files, or 1 file with 8 lines?
Show us what's in the file(s).
I have 8 files containing short text statements. One file for each label.
I have a List of 8 items to match the 8 labels where I display the file data. So it sounds like I have to create a list for the 8 files.
The goal is to initialize at start up and read from the 8 files and populate the data in the labels. So I have to always update the label List with data changes. The file list won't change as each index is contained within the filename: audioFile1.3gp, audioFile2.3gp, audioFile3.3gp, etc.
I'll work on your suggestions and that sounds like that will work. Thank you all very much!!
Just to know how it is work.
The File.GotText block gives back a File component, but in the setLabel.Text does wait for a Label component. That gives the error. So your different non-file structures can only work if you modify a property of that same component in the "body block" (green) that you relate to in the "frame block"(yellow-ish?).
When I hear some one populating a number of Labels automatically, I refer them to the ListView component.
For your app, I recommend keeping a Table of Contents text file with two columns,
- Readable name of sound file ("Southern Redbreasted Warbler")
- srbw.3gp (audio file name for that bird)
in CSV table format, and loading it at Screen1.Initialize from
FileTableOfContents, a File component devoted to loading the Table of Contents.
When that File's text arrives, convert it to a list of lists, then send column 1 into the Elements of a ListView or List Picker.
On selection, look up the audio file name from the list of lists and load that into your Player.